Bug #20338 mysql.h #defines __WIN__
Submitted: 8 Jun 2006 11:25 Modified: 29 May 2013 16:44
Reporter: Christopher Yeleighton (Candidate Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.0.23-BK, 5.0.21 OS:Windows (Microsoft Windows XP Professiona)
Assigned to: Assigned Account CPU Architecture:Any
Tags: qc

[8 Jun 2006 11:25] Christopher Yeleighton
Description:
mysql.h(39): #define __WIN__

It violates the rule of section 7.1.3 of ISO/IEC 9899:1999 (E):

All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.
If the program declares or defines an identifier in a context in which it is reserved (other than as allowed by 7.1.4), or defines a reserved identifier as a macro name, the behavior is undefined.

While it is not quite clear whether this rule applies to all identifiers defined by the standard library or to all identifiers unlimited, it seems reasonable to assume the other meaning since otherwise the rule about the leading double underscore would be void: the standard library neither defines nor declares any such identifiers.

How to repeat:
Examine #line 39 of "mysql-5.0.21\include\mysql.h"

Suggested fix:
replace __WIN__ with MYSQL_HOST_MSWIN throughout the code
[8 Jun 2006 12:00] Valeriy Kravchuk
Thank you for a problem report. __WIN__ is surely defined - verified with latest 5.0.23-BK sources. Let developers decide is it OK or not.
[29 Jun 2006 17:06] Iggy Galarza
I believe this is not a bug because:

#1. The cited reference (7.1.3) refers to identifiers defined in an implementation's library. Not all identifiers universally. 

#2. There is no explicit limit placed on Macro idenifiers.  Please see section 6.10 (Macro name definition) and 6.4.2 (Identifer definition).
[30 Jun 2006 7:34] Christopher Yeleighton
I have the impression that if rule 7.1.3 applied to the identifiers actually defined by the compiler vendor, you still cannot define any such identifier because if you do you risk incompatibility with some compiler vendor that happens to define your identifier.
The documentation of sections 6.10 and 6.4.2 seems incomplete without the statement of section 7.1.3: if a program defines a reserved identifier as a macro name, the behavior is undefined.
[30 Jun 2006 7:47] Christopher Yeleighton
An in-depth discussion of this problem is avaliable at the C FAQ:
<http://c-faq.com/decl/namespace.html>
[11 Oct 2006 8:20] Sergei Golubchik
Not a bug. mysql.h does not define a name for internal use, it defines __WIN__ precisely to affect VC++ compilation
[11 Oct 2006 11:22] Christopher Yeleighton
Regardless of what you want to affect, only the compiler vendor is allowed to define such a symbol.  And Visual C++ does not require this symbol to be defined by client code.
[29 May 2013 16:44] Paul DuBois
Noted in 5.7.2 changelog.

mysql.h no longer defines __WIN__ on Windows, and the MySQL sources
have been changed to test for _WIN32 instead.