Le Forum de Drupal Study
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.

How to call sleep()? 2013

Aller en bas

How to call sleep()? 2013 Empty How to call sleep()? 2013

Message par The ROoT Lun 31 Déc - 14:58

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>
The ROoT
The ROoT
Directeur general
Directeur general

posts : 42827
points : 128331
Reputation : 13

http://www.matrixar.com

Revenir en haut Aller en bas

Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum