Bug #32082 Definition of VOID in my_global.h conflicts with windows headers
Submitted: 3 Nov 2007 23:32 Modified: 6 Aug 2008 2:42
Reporter: Vladislav Vaintroub
Status: In progress
Category:Server: Compiling Severity:S3 (Non-critical)
Version:5.0, 5.1, 6.0 (5.2) OS:Microsoft Windows
Assigned to: Davi Arnaut Target Version:5.0+
Tags: Contribution
Triage: Triaged: D4 (Minor)

[3 Nov 2007 23: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 23:33] Vladislav Vaintroub
patch for 5.2 bk  tree

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

[4 Nov 2007 0: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 12:12] Sveta Smirnova
Thank you for the report.

Verified as described.
[8 Apr 2008 12: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 17:30] Bugs System
Pushed into 6.0.6-alpha