c++ preproccessor
Name:
Anonymous
2007-11-17 22:07
I want to include windows.h if my program is being compiled in windows, but unistd.h if in linux...
something like this:
#if _WIN32
#include <windows.h> // for Sleep()
#if else
#include <unistd.h> // for sleep()
#endif
How would I do this?
Name:
Anonymous
2007-11-17 22:19
#if _WIN32
#include <windows.h> // for Sleep()
#if else
#include <unistd.h> // for sleep()
#endif
Name:
Anonymous
2007-11-17 22:19
#if _WIN32
//......
#else
//......
#endif
Name:
Anonymous
2007-11-17 23:34
#if _WIN32
# include <windows.h>
# define Sleep(x) Sleep(x, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
#else
# include <unistd.h>
#endif
Name:
Anonymous
2007-11-17 23:36
Name:
Anonymous
2007-11-17 23:42
GNU AUTOTOOLS, MOTHERFUCKER, DO YOU KNOW HOW TO ./configure ?
Name:
Anonymous
2007-11-18 0:11
Name:
Anonymous
2007-11-18 5:50
>>6
You're a fool. OP is asking specifically about the preprocessor, gtfo with your recursive acronym automated bullshit.
Name:
Anonymous
2007-11-18 7:53
#ifdef WIN32
#include <windows.h>
#define mssleep(d) Sleep(d)
#else
#define mssleep(d) usleep(1000*d)
#include <unistd.h>
#endif
Name:
Anonymous
2007-11-18 7:54
>>9
Correction :
#ifdef WIN32
#include <windows.h>
#define mssleep(d) Sleep(d)
#else
#include <unistd.h>
#define mssleep(d) usleep(1000*d)
#endif
Name:
Anonymous
2007-11-18 7:55
sleep(d) sleeps for d seconds
Sleep(d) sleeps for d milliseconds
Solution : usleep(d*1000) for 1ms
Name:
Anonymous
2007-11-18 15:18
usleep(d*1000) for 1ms
Lol, what?
Name:
Anonymous
2007-11-18 16:21
Name:
Anonymous
2007-11-19 2:23
>>13
Oh, I wasn't aware there was a function which could sleep at that fine granularity. Boy is my face red.
Name:
Anonymous
2007-11-19 9:38
It's Unix, not Windows. It's meant to be good.
Name:
Anonymous
2010-11-15 6:19