really strange x-file stuff with .h definitions ?¿

hi all …

sorry for this curious ‘subject’ …

i can’t believe what i’m seeing and i hope somebody will have a simple answer to a weird behaivour in OF . (i work under DEVcpp in Win XP) …

i’ll try to explane what happened : i was cleaning code and changing some spelling when i get to a point where …

if i delete a “int diffDelay” wariable declaration on the .h (!!which it was NOT used on the .cpp or in the whole project) the executable runned and showed me just 2 textures (my application should show 3!!) …

and if i just add again in the .h a “int XXwhatever” (and not using XXwhatever on the cpp’s) … the code runs perfectly as it used.

everytime that i made some changes on the .h i’m making a clean and full compilation …

I’ve been coming back to the previous working version and make the cleaning much more carefully and i always get to the same point !!!

when i delete a certain variable on the .h (that is not used) it doesn’t work properly . if i just add that declaration, and not putting any code it works fine …

How can including or not some new variables make my code go crazy ?
please tell me that i’m not getting crazy … ?¿
is that possible ? is that a DevCpp stuff ?? any comments please ?

i’m quite sure there has to be a stupid reason for that, but i’ve some days now with this …

e*

I believe the problem is with the compiler

dev-c++ is *free* and therefore (cough) buggy

do “clean” and recompile after you change, does the problem go away?

I’ve seen ALOT of voodoo with dev-c++ that dissapears when you clean and recompile or “touch” the corresponding cpp files that need to be recompiled.

hope that helps
zach

do clean and recompile, afther you change, does the problem go away ?

nop. i’ve clean trough the DEVcpp ‘Clean’, and manually delting the /obj … and the problem keeps on …

I believe the problem is with the compiler
dev-c++ is *free* and therefore (cough) buggy

uuuuhhh !! really !!! ahhhh !! that’s a bad news and a shamme thing !!

or “touch” the corresponding cpp files that need to be recompiled
what do you mean with this ? If i rebuild all, all the cpp are recompiled isn’t ?
is the DevCpp voodoo with file managing or with compilation process ??

another strange thing has come when i got different results if i execute from the DevCpp framework by ‘Run’ or directly from the folder … that’s unbelievable !!

:_(

should then i split to CodeWarrior ? or which other “acceptable” compiler has lesss voodoo’s ? :wink:

thanks for info …

e*

can you please post a zip of what is causing you trouble, apps and libs? and document the problems. I’ve seen voodoo before, but nothing that strange…

I think you might have an allocation error if cleaning doesn’t help.

for example, if you have a boolean variable and you don’t set it to be true or false before you use, it can change based on what you do in the h file (ie, the boolean variable references a new place in memory based on the new thing you’ve added to the h file). for example:

  
  
in h:   
  
bool myBool  
  
in .cpp   
  
if (myBool) {  
  
}  
  

if you never say myBool = false, etc before you use, myBool has the value of *whatever* was in that location of memory at the time the app is run. you can have ALOT of voodoo that way.

the next step I think might be to check your variables - do you initialize all of them properly?

this would make sense too about getting different results depending on where you run the app - different memory address for the variables = different results.

hope that helps
zach

hola zach :wink: thanks again

i use to initialize all the variables on the ofSetup().
i’ve checked that out and yes they’re all setup to a default value at start before using them.

one question regarding arrays and structs :

for example … if i’ve a : unsigned char * FRAME …
is it ok to initialize it like this :

FRAME = new unsigned char[w*h*3];

or should i use malloc() ?

another question would be about structs arrays …
could i initialize like this ?

.h
struct (…) structE;

.cpp

myStruct = new structE[Num];
and then initializing every field present on the strucE ?

About sending a ZIP … i tried to make a smaller demo thing for you but when i start to take things out from the project (.h and .cpp) the behaiviour changes so it’s difficult to make a small release for you to check up my error … May i send u the whole project or it’s going to be impossible to debug for you ?

another question regarding initialization.

i’ve made an extension for ofTexture with some extra functions and methods i needed.

this is the .h

class PmTexture : public ofTexture{

public:

PmTexture();
~PmTexture();

void flipH(bool mode);
void flipV(bool mode);
void drawLateral(int x, int y,int z);
bool mflipV,mflipH;
};

#endif

my doubt now is how do i make a new texture of this PmTexture type ?
should i use

PmTexture pT = new PmTexture(); ???

and then implement a

void PmTexture::PmTexture(){
mflipV = false;
mflipH = false;
}

the thing is that i’ve 2 new bools on this extension class and i don’t know how to manage the creation of it …

hi just post everything – libs and apps

I have a fast internet connection and also a tremendous amount of laziness to recreate projects, so if I can just open it and compile it, much better :slight_smile:

also, please make a small note in the code about where the strange behavior is happening, ie, in comments, so I can try it. Ie,

when you comment this, this happens,
uncomment this, this happens.

it might be something really small – I still suspect variables.

your allocations look ok

take care
zach

hola zach …

well after diving some more hours finally i think i got the “error” …
on my diving i was finding more vodoo behaviours that i couldn’t understand .

one of the things i did before starting to find voodoos was to create an inherited class of ofTexture to add my necessary code and addons to ofTextures.

the point was (as u previsualized) an initialization issue. All my variables where correctly initialized but my “fault” was on the CONSTRUCTOR of the derived class of ofTexture.

i had a mistake on how i was understanding inheritance and the relation of constructors in this process. Finally after reading some C++ tutorials i understood the whole thing .

i was making an incorrect constructor for the derived class so “2 booleans” where initialy lost and no correctly initialized as my constructor for my derived class was not set properly.

so … i made a DerviedTexture() constructor initializing the new variables that my derived class had (2 booleans) and i came back to “reality coding” and left “vodoo” for the B series tv-films … ;-)))))))))))

thanks for your patience … it was my first “derived” class after some forum reprimands for hacking OF classe … ;oP

e*

cool !

sounded like an unallocated variable, or something like that.
glad you are up and rolling !!

take care,
zach