Page 1 of 1

Not sure if this is related to CEGUI buuuuuuuuuut.....

Posted: Fri Mar 25, 2005 13:04
by wingdongdoodle
well, i've been having great success gettign CEGUI and OPENGL working, im setting up a simple framework and some classes that will make it a lot easier to set up GUIS using CElayout editor and such.

Ive also recently started tryign to integrate Raknet (a very nice networking library) with all my code. however...

raknet requires (? maybe not REQUIRES but as far as i know at this point) a struct to send data through packets, and this struct needs the #pragma pack(1) .

so i wrote a .H file that contained my struct:
#pragma pakc(1)
struct CQubitB92{
unsigned int typeID;
unsigned int mLinearAngle;
}

since i just typed a lot of code, i decided to compile and give it a test (make sure no types since i did write it at 5 am :roll: ). it compiled, ran fine, etc.

until i exit. my program crashes on my applicatiosn destructor on this command:

if(CEGUI::System::getSingletonPtr())
delete CEGUI::System::getSingletonPtr();

the error message i get is: DAMAGE: after normal block (467) *numbers*

nowhere in my code do i even instatiate a instance of the struct. If i comment out #pragma pack(1), then the code works fine...


I'm not sure what is causign the problem, it could be me (i have never used the pack() thing before, just learned it a few hours ago) or something weird.


anywho, any ideas would be welcome. (btw, im on visual c++ 7.1, and i have the newest compilers for it, i downloaded the newest Visual Toolkit and got that workign with my IDE)




EDIT:

ok, after much more research/forum searching, i discovered that i should #pragma pack(push) .... #pragma pack(pop) and this gets rid of my problem. Still, anyone know why i was getting that problem above? im assuming now that memory was overwritten somewhere?

Re: Not sure if this is related to CEGUI buuuuuuuuuut.....

Posted: Fri Mar 25, 2005 15:03
by CrazyEddie
I have no explantion for you, I've never used the #pragma pack either :?

The only thing that springs to mind is some wierdness caused by compiling the lin with one setting and somehow getting a different setting when using the library. I know that's far fetched, since pack is only supposed to affect the construct immediately following it.

Very odd.

CE.

Re: Not sure if this is related to CEGUI buuuuuuuuuut.....

Posted: Sat Mar 26, 2005 23:16
by kitt3n
#pragma pack(1) will cause all folowing structs
to be byte-aligned

You nicely see the result like this:

<whatever #pragma pack here>
struct myStruct
{
char myBytes;
int myInt; // If aligning on 4-byte boundaries
// myInt will start 3 bytes further
// than myBytes (ie 3 bytes are 'lost'
// #pragma pack(1) is great for structures
// you wanna write to disk - at the cost
// of some performance (non-aligned data
// is slower
};

int mySize = sizeof (myStruct);


Damage after normal block is usually a memory-boundary
error... You might try boundchecker -
or alternatively rip down your program until the error
doesn't occur anymore :)

Re: Not sure if this is related to CEGUI buuuuuuuuuut.....

Posted: Sun Mar 27, 2005 01:58
by gcarlton
The crash will be that your side defines structs as packed, but the cegui library is compiled without them packed, and as such you'll get weird problems, since the code will assume two different sizes at different points.