Bug #28340 bad choice of name #define sleep(A) Sleep( (A)*1000) causes bugs in boost
Submitted: 9 May 2007 19:07 Modified: 4 Mar 2013 10:37
Reporter: Clark Sims Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S4 (Feature request)
Version:4.1/5.0/5.1 OS:Other (windows issue)
Assigned to: CPU Architecture:Any
Tags: #define, config-win.h, sleep, sleep, windows

[9 May 2007 19:07] Clark Sims
Description:
line 182 of config-win.h   
#define sleep(A)  Sleep((A)*1000)

will cause a bug in any class that has a member function named sleep. For example,  the boost threads library has a function named sleep.

sleep   is a *REALLY*  bad name for a macro, because it will surely cause conflicts in many other peoples code.

How to repeat:
#include <boost/thread/thread.hpp>

#include "config-win.h"

do anything to call thread::sleep

Suggested fix:
remove the line  #define sleep   from config-win.h
[9 May 2007 20:01] MySQL Verification Team
Thank you for the bug report.

Z:\bk>cat mysql-4.1\include\config-win.h | findstr sleep(A)
#define sleep(A)  Sleep((A)*1000)

Z:\bk>cat mysql-5.0\include\config-win.h | findstr sleep(A)
#define sleep(A)  Sleep((A)*1000)

Z:\bk>cat mysql-5.1\include\config-win.h | findstr sleep(A)
#define sleep(A)  Sleep((A)*1000)
[29 Oct 2007 12:35] Timour Katchaounov
I agree that this is not the most convenient name, but there are
workarounds, e.g.
- redefine sleep,
- then undefine it,
- then include your favorite library

This is a feature request, so changing severity accordingly.
[4 Mar 2013 10:37] Yngve Svendsen
There is a workaround, although slightly inconvenient, and we do not plan to implement this change.