[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.

svn path=/trunk/boinc/; revision=4767
This commit is contained in:
Bruce Allen 2004-12-06 16:03:13 +00:00
parent 11b088afe2
commit 2540d049ec
4 changed files with 41 additions and 8 deletions

View File

@ -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

View File

@ -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" {

View File

@ -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

View File

@ -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