How to call sleep()? 2013
Page 1 sur 1
How to call sleep()? 2013
1. I cannot find a header file to #include that has the sleep function prototype.
2. When I add my own sleep function prototype, I get an unresolved external reference error (for _sleep, not sleep).
What must I #include to get the sleep function prototype?
What lib must I include in the linker configuration to resolve the external reference?
(I suspect that if I #include the correct header file, the second question might become moot.)
-----
The "man page" at [Vous devez être inscrit et connecté pour voir ce lien] says the header file is .
But #include'g only results in compilation errors.
A response marked "answer" at [Vous devez être inscrit et connecté pour voir ce lien] says [sic].
#Include'g only does eliminate the compilation errors.
But apparently that does not bring in the sleep function prototype. Neither does also subsequently #include'g .
(Which seems to be #include'd by anyway.)
-----
But even with my own function prototype shown below, I get an unresolved external reference for _sleep.
Note: not for sleep per se. Is that a symptom of my problem: my sleep reference is changed to _sleep? If so, how can avoid that?
According to "man page" (see link above), the external should be resolve in kernel32.lib.
And kernel32.lib does appear in the "Additional Dependencies" list under Configuration Properties \ Linker \ Input.
PS: Since I am not using C++ features, I tried setting "Compile as C" under Configuration Properties \ C/C++ \ Advanced, to no avail.
-----
My code....
#include "stdafx.h"
#include
#include
#include
void sleep(DWORD msec); // added later
int _tmain(int argc, char* argv[])
{
time_t st, et;
st = time(NULL);
sleep(2000);
et = time(NULL);
printf("%ld\n%ld\n%ld\n", st, et, et-st);
printf("press Enter to terminate");
getchar();
return 0;
}</div>
2. When I add my own sleep function prototype, I get an unresolved external reference error (for _sleep, not sleep).
What must I #include to get the sleep function prototype?
What lib must I include in the linker configuration to resolve the external reference?
(I suspect that if I #include the correct header file, the second question might become moot.)
-----
The "man page" at [Vous devez être inscrit et connecté pour voir ce lien] says the header file is .
But #include'g only results in compilation errors.
A response marked "answer" at [Vous devez être inscrit et connecté pour voir ce lien] says [sic].
#Include'g only does eliminate the compilation errors.
But apparently that does not bring in the sleep function prototype. Neither does also subsequently #include'g .
(Which seems to be #include'd by anyway.)
-----
But even with my own function prototype shown below, I get an unresolved external reference for _sleep.
Note: not for sleep per se. Is that a symptom of my problem: my sleep reference is changed to _sleep? If so, how can avoid that?
According to "man page" (see link above), the external should be resolve in kernel32.lib.
And kernel32.lib does appear in the "Additional Dependencies" list under Configuration Properties \ Linker \ Input.
PS: Since I am not using C++ features, I tried setting "Compile as C" under Configuration Properties \ C/C++ \ Advanced, to no avail.
-----
My code....
#include "stdafx.h"
#include
#include
#include
void sleep(DWORD msec); // added later
int _tmain(int argc, char* argv[])
{
time_t st, et;
st = time(NULL);
sleep(2000);
et = time(NULL);
printf("%ld\n%ld\n%ld\n", st, et, et-st);
printf("press Enter to terminate");
getchar();
return 0;
}</div>
Sujets similaires
» Mac goes into deep sleep sometimes 2013
» System sounds sometimes gone after waking from sleep 2013
» HD Light Solid After Sleep Mode 2013
» Screen freezing/blanking when coming out of sleep 2013
» Windows 7 - Why does my CPU usage spike when my monitor goes to sleep? 2013
» System sounds sometimes gone after waking from sleep 2013
» HD Light Solid After Sleep Mode 2013
» Screen freezing/blanking when coming out of sleep 2013
» Windows 7 - Why does my CPU usage spike when my monitor goes to sleep? 2013
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum