1. RE: MEMORY corruption and windows programming ???
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Jun 09, 2003
- 364 views
> From: Bernie Ryan [mailto:xotron at bluefrognet.net] > Below is what MSDN states about BOOL type. > Does anyone have any idea about how we can write windows code > that will be compatible and not cause memory corruption errors > when runing euphoria code. > What size does everyone use for bool in a structure that will > always work ?? > > Bernie > > " Microsoft Specific > In Visual C++4.2, the Standard C++ header files contained a > typedef that equated bool with int. In Visual C++ 5.0 and > later, bool is implemented as a built-in type with a size > of 1 byte. That means that for Visual C++ 4.2, a call of > sizeof(bool) yields 4, while in Visual C++ 5.0 and later, the > same call yields 1. This can cause memory corruption problems > if you have defined structure members of type bool in Visual > C++ 4.2 and are mixing object files (OBJ) and/or DLLs built > with the 4.2 and 5.0 or later compilers. > END Microsoft Specific " IIRC, the only time I've had to worry about a BOOL being 1 byte is when there are multiple BOOL's next to each other, since the compiler seems to like to pad extra bytes in order to get everything else 4-byte aligned. By default, I assume a 4-byte BOOL, until I crash and burn. :) Matt Lewis
2. RE: MEMORY corruption and windows programming ???
- Posted by Bernie Ryan <xotron at bluefrognet.net> Jun 09, 2003
- 368 views
Matt wrote: >> IIRC, the only time I've had to worry about a BOOL being 1 byte is when >> there are multiple BOOL's next to each other, since the compiler seems to >> like to pad extra bytes in order to get everything else 4-byte aligned. By >> default, I assume a 4-byte BOOL, until I crash and burn. :) Thanks Matt and Al: I guess I'll just have to use 4-bytes and hope things don't crash too much. Bernie