>Is this the proper way of writing a cross-platform sleep function? No. Move the platform specific includes into a C file and make sleepSeconds a function not a macro.
Juan Taylor
#if defined(unix) || defined(__unix__) || defined(__unix) #include void sleepSeconds(int a) { sleep(a); } #elif defined(_WIN32) #include void sleepSeconds(int a) { Sleep(a * 1000); } #else #include void sleepSeconds(a) { assert(0 && "sleepSeconds() not implemented for this OS!"); } #endif
So this is the proper way?
Bentley Miller
bait
Sebastian Adams
Nah, I'm just bad at being a cnile
Kayden Powell
SLEEP(3) Linux Programmer's Manual SLEEP(3) RETURN VALUE Zero if the requested time has elapsed, or the number of seconds left to sleep, if the call was interrupted by a signal handler.
Austin Edwards
>Linux I need it to work on other OSs too. And I don't need anything complicated anyways.
Henry Peterson
>>C lang has no standard wait function When you get to "real" programming, you realise how not useful a sleep function like that really is.
Christopher Thompson
I'm writing a program that "presses" a button on a webpage automatically after a set amount of wait time. So in this situation it's needed.
Brayden Hernandez
write for POSIX and if you need to suck Bill Gates cock install mingw
Robert Butler
Just use select().
Isaiah Miller
>suck Bill Gates cock install mingw mingw is a pain in the ass to install and use
no, you're supposed to have 2 seperate files for windows and unix, which will contain the implementations then you put a function prototype in the header like this void sleepSeconds(int);
then you link the unix code if it's the unix makefile, or link the windows code if it's the windows build script
Matthew Bennett
Thanks for the info, user! I'll go learn cross-platform makefiles then
Jaxon Carter
GCC and Clang both default to C11 and even the Linux kernel has moved onto it.
Andrew Flores
You are reinforcing his point.
Lucas Wood
Learn CMake.
Ryan Thompson
epic xdd
Josiah Jenkins
>writes a C program that can be implemented in 5 lines of javascript Peak Any Forums moment.
Andrew Jones
I want to run it 24/7 on my phone so I don't want the heavy burden of Node