sync()


mrsnature

Member
Joined
Jul 22, 2003
Messages
462
I've tried adding sync() to my C++ program, after writing to a high score file. Dev-C++ reports that the "sync" function is undeclared... what should I include to enable this to work?

Thanks for any help!

EDIT: I've tried using #include <unistd.h> but to no avail...

EDIT: <thanks mod>
 
i call sync from the shellscript that launches the app

did you include syscall.h?

CODE

#include <syscall.h> // or it might be <sys/syscall.h>
#include <unistd.h>



and call like

CODE

syscall(SYS_sync);



i forget if its <sys/syscall.h> or just <syscall.h>

may also need types.h

its been a while since i did it this way
 
thanks, i couldn't find syscall.h, then realised: i was compiling as a windows executable, compiling for gp2x does not present any errors about using "sync();"

I guess its a linux only function, can somebody confirm this?

Thanks
 
yeah it is a linux only kernel function, but the devkit should have the headers and libs for the call since gp2x is linux...
 
You should be able to just system("sync"); (unless the gp2x does not have the sync binary for some reason). But I guess any way that works is fine. (doesn't depend on linux-specific headers... Should still compile for windows, although I'm not sure what exactly will happen when it reaches the system("sync") line itself.)
 
Back
Top