diff --git a/api/boinc_api.h b/api/boinc_api.h index 0471a74bf5..740479aae6 100755 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -22,8 +22,12 @@ /* to allow prototypes using 'bool' in ANSI-C */ #if (!defined __cplusplus) && (!defined bool) -# define bool int -#endif +#if ((defined(_MSC_VER)) && (_MSC_VER > 1020)) +#define bool char +#else +#define bool int +#endif /* defined(_MSC_VER) && (_MSC_VER > 1020) */ +#endif /* (!defined __cplusplus) && (!defined bool) */ /* ---------------------------------------------------------------------- * ANSI C API BEGINS HERE diff --git a/api/graphics_api.h b/api/graphics_api.h index a03339c428..351243bd7d 100755 --- a/api/graphics_api.h +++ b/api/graphics_api.h @@ -6,8 +6,12 @@ */ /* to allow prototypes using 'bool' in ANSI-C */ #if (!defined __cplusplus) && (!defined bool) -# define bool int -#endif +#if ((defined(_MSC_VER)) && (_MSC_VER > 1020)) +#define bool char +#else +#define bool int +#endif /* defined(_MSC_VER) && (_MSC_VER > 1020) */ +#endif /* (!defined __cplusplus) && (!defined bool) */ #ifdef __cplusplus extern "C" { diff --git a/checkin_notes b/checkin_notes index 4c511c66f1..7f0081514f 100755 --- a/checkin_notes +++ b/checkin_notes @@ -20732,3 +20732,23 @@ David 5 Dec 2004 boinc_db.h lib/ util.C,h + +Bruce 6 Dec 2004 [thanks to Bernd Machenschalk!] + + - Fixed 'time to checkpoint' problem under Win32 with pure C code. + It turns out that MS VC++ up to version 4.2 defines bool as INT. + But more recent VC++ defines bool as CHAR. This broke + boinc_time_to_checkpoint() under Win32, when used within pure ANSI + C code, if you treated the return value as a bool. So this patch + defines bool as char if using C under recent MS compilers. + + David, a better solution for API functions that should be + callable from C is to make them return 'int' not 'bool'. + Probably ditto for Fortran. Sigh. + + api/ + boinc_api.h + graphics_api.h + + lib/ + filesys.h diff --git a/lib/filesys.h b/lib/filesys.h index 5e159f839c..4a2cde8eb5 100755 --- a/lib/filesys.h +++ b/lib/filesys.h @@ -26,11 +26,16 @@ #ifndef _FILESYS_ #define _FILESYS_ -/* to allow prototypes using 'bool' in ANSI-C */ +/* to allow prototypes using 'bool' in ANSI-C. Note that gcc defines + bool as an INT, and MS VC++ up to version 4.2 also does. However + more recent versions of MS VC++ define bool as CHAR. */ #if (!defined __cplusplus) && (!defined bool) -# define bool int -#endif - +#if ((defined(_MSC_VER)) && (_MSC_VER > 1020)) +#define bool char +#else +#define bool int +#endif /* defined(_MSC_VER) && (_MSC_VER > 1020) */ +#endif /* (!defined __cplusplus) && (!defined bool) */ #ifdef _WIN32