Bug #25529 C API - problem on Win32 - typedef to bool
Submitted: 10 Jan 2007 18:21 Modified: 10 Feb 2007 19:20
Reporter: Allann Silva Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S2 (Serious)
Version:5.0.27 OS:Windows (Microsoft Windows 2000)
Assigned to: Assigned Account CPU Architecture:Any

[10 Jan 2007 18:21] Allann Silva
Description:
Hi, I has some problems while trying to build a program written in C++ (Windows 2000, Microsoft Visual Studio 6.0 - in Linux I don't have this problem) that uses MySQL client library (I'm using CMake to build), I've solved the problem modifying the 'include/config-win.h' file, the problem was with the typedef to 'bool', a verification must be made to check if the build is in a C++ environment. Is the solution correct for you?

Follows the patch, the important part is only:

+#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
 #define bool BOOL
+#endif

I has cloned the verification from 'include/my_global.h'.

Thank you.

The diff:

--- config-win-orig.h    Sun Oct 22 04:30:22 2006
+++ config-win.h    Thu Jan 04 17:45:21 2007
@@ -154,7 +154,11 @@
 
 #define Socket_defined
 #define my_socket SOCKET
+
+#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
 #define bool BOOL
+#endif
+
 #define SIGPIPE SIGINT
 #define RETQSORTTYPE void
 #define QSORT_TYPE_IS_VOID

How to repeat:
On include 'include/config-win.h' through 'include/my_global.h' on a Windows application the bool type is redefined.

Suggested fix:
Follows the patch, the important part is only:

+#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
 #define bool BOOL
+#endif

I has cloned the verification from 'include/my_global.h'.

Thank you.

The diff:

--- config-win-orig.h    Sun Oct 22 04:30:22 2006
+++ config-win.h    Thu Jan 04 17:45:21 2007
@@ -154,7 +154,11 @@
 
 #define Socket_defined
 #define my_socket SOCKET
+
+#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
 #define bool BOOL
+#endif
+
 #define SIGPIPE SIGINT
 #define RETQSORTTYPE void
 #define QSORT_TYPE_IS_VOID
[10 Jan 2007 19:20] MySQL Verification Team
Thank you for the bug report. Could you please provide a small console
client application which presents the behavior reported?. I will test
with VS2003/2005 because VS 6.0 isn't more supported to compile client
and servers build. Thanks in advance.
[11 Feb 2007 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".