Bug #32082 Definition of VOID in my_global.h conflicts with windows headers
Submitted: 3 Nov 2007 22:32 Modified: 16 Jun 2010 12:18
Reporter: Vladislav Vaintroub Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.0, 5.1, 6.0 (5.2) OS:Windows
Assigned to: Davi Arnaut CPU Architecture:Any
Tags: Contribution

[3 Nov 2007 22:32] Vladislav Vaintroub
Description:
my_global.h defines VOID essentially as
#define VOID(x) x
The intention is to avoid lint warnings about ignored return value of some functions like printf().The problem however is that this defintion is incompatible with VOID as defined by Windows SDK headers that come with Visual Studio 8

winnt.h:255
#define VOID void

As a consequence trying to include <windows.h>, if my_global.h is also included will lead to warning. Trying to include some other windows header e.g dbghelp.h leads to compile error.

How to repeat:
in mysqld.cc
after
#include "my_global.h"
insert

#ifdef __WIN__
#include <windows.h>
#include <dbghelp.h>
#endif

recompile mysqld.cc, see compiler error

Suggested fix:
-remove the definition of VOID from my_global.h
-replace all occurences of 
VOID(somefunction(someparam)); with (void)somefunction(someparam);

In my understanding (void)myfunc() is quite portable way of telling lint to keep silent about not checking return code.
[3 Nov 2007 22:33] Vladislav Vaintroub
patch for 5.2 bk  tree

Attachment: patch.txt (text/plain), 213.27 KiB.

[3 Nov 2007 23:28] Vladislav Vaintroub
Small correction to the "how to repeat" section
mysqld.cc does not include mysql_global.h directly, but via mysql_priv.h

so test case would be to change

#include "mysql_priv.h"
at the start of the file to

#include "mysql_priv.h"
#ifdef __WIN__
#include <windows.h>
#include <dbghelp.h>
#endif
[9 Dec 2007 11:12] Sveta Smirnova
Thank you for the report.

Verified as described.
[8 Apr 2008 10:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45053

ChangeSet@1.2571, 2008-04-08 12:30:06+02:00, vvaintroub@wva. +122 -0
  Bug#32082 : definition of VOID in my_global.h conflicts with Windows
  SDK headers
  
  VOID macro is now removed. Its usage is replaced with void cast.
  In some cases, where cast does not make much sense (pthread_*, printf, 
  hash_delete, my_seek), cast is ommited.
[13 May 2008 15:30] Bugs System
Pushed into 6.0.6-alpha
[24 Nov 2009 13:56] Konstantin Osipov
Queued in 5.6 (next-mr-runtime).
[24 Nov 2009 13:56] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/91422
[25 Nov 2009 13:33] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091124194633-yc0achgq1ioyqzng) (version source revid:alik@sun.com-20091124194633-yc0achgq1ioyqzng) (merge vers: 6.0.14-alpha) (pib:13)
[25 Nov 2009 13:33] Bugs System
Pushed into 5.6.0-beta (revid:alik@sun.com-20091124193905-3iyzegd75k4givuz) (version source revid:kostja@sun.com-20091124135459-klvuwbvth0iahfbu) (merge vers: 5.6.0-beta) (pib:13)
[25 Nov 2009 15:45] Paul DuBois
No changelog entry needed.
[6 Mar 2010 11:00] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@mysql.com-20091125142014-7asc9sj33gzki0ym) (merge vers: 5.6.0-beta) (pib:16)
[6 Mar 2010 19:59] Paul DuBois
No changelog entry needed.
[15 Jun 2010 8:15] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100615080459-smuswd9ooeywcxuc) (version source revid:mmakela@bk-internal.mysql.com-20100415070122-1nxji8ym4mao13ao) (merge vers: 5.1.47) (pib:16)
[15 Jun 2010 8:32] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100615080558-cw01bzdqr1bdmmec) (version source revid:mmakela@bk-internal.mysql.com-20100415070122-1nxji8ym4mao13ao) (pib:16)