On Feb 10, 2009, at 9:22 AM, Dick Hollenbeck wrote:




BOOL isn't defined in C. bool exists in C99 if you include <stdbool.h>. My interest was in getting the build working again, not making it pretty. If you want to use BOOL, make a patch that introduces the type correctly. I'm also OK with using stdbool.h as it is a standard.


See here:

http://www.codeguru.com/forum/archive/index.php/t-385543.html




Right, stdbool is part of C99 and doesn't exist in C89. The complaints about a C++ compiler not supporting it are pointless. C++ has a native boolean type so it doesn't need stdbool. This confusion between using C89, C99, and C++ is exactly why many C programmers avoid using booleans and just use int.

Note that the first removal of BOOL usage was in r1367 and it was rather incomplete. I'm not really happy that that occurred. r1368 was a quick hack to get the compile working again, but clearly it wasn't complete.

I'm reverting r1367-1368 and making the usage of booleans in OpenOCD compliant with C++ and stdbool. This does change the name of the type to "bool" and the constants are now lower case. I'm also moving the definition of the boolean type to types.h. The support works as follows:
- If stdbool.h exists (tested by configure), use it
- Else if we are using C++, do nothing
- Else define bool as an int, true as 1, and false as 0

It should work on any C89, C99, or C++ compiler. I've tested it with gcc on OS X but was unable to compile with g++ due to a type conversion error in binarybuffer.c. I have no other systems to test it with. Please update to r1369 and try compiling it on various platforms. Note that you will need to rerun bootstrap as configure.in has changed.

--
Rick Altherr
[email protected]

"He said he hadn't had a byte in three days. I had a short, so I split it with him."
 -- Unsigned



Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to