News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Sleep() function errors

Started by Vlad417, June 05, 2007, 07:49:06 PM

Previous topic - Next topic

Vlad417

when i try to compile a program using Sleep(); i get an error for everytime 'DWORD' is stated in the 'winbase.h' header.

is there any way to get around this or another function i could use to pause the program for variable  lengths?

Another question: How could i full screen the program?

darthdespotism



raph

Please post the exact error message.

patlecat

I've just compiled a program with Sleep() using GCC4.2 and CB 4051, it works perfectly well (under WinXP-SP2).

Vlad417

C:/Program Files/CodeBlocks/include/winbase.h:607: error: `DWORD' does not name a type
C:/Program Files/CodeBlocks/include/winbase.h:608: error: `DWORD' does not name a type
C:/Program Files/CodeBlocks/include/winbase.h:609: error: `DWORD' does not name a type
C:/Program Files/CodeBlocks/include/winbase.h:610: error: `DWORD' does not name a type
Process terminated with status 1 (0 minutes, 2 seconds)
52 errors, 1 warnings



Some specs
Compiler: GNU GCC
Windows XP SP2
AMD Athlon64 3500+

stahta01

This works for me under minGW GCC, but I could not get Sleep() or sleep() to work OK, I am guessing that I am missing an needed header.
Tim S


#include <iostream>

using namespace std;

int main()
{
cout << "Going to Sleep!" << endl;
    _sleep(10000); // time in milliseconds
cout << "Hello world!" << endl;
return 0;
}
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

TDragon

Quote from: stahta01 on June 05, 2007, 11:34:22 PM
... I am guessing that I am missing an needed header.
That would be windows.h.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

DaVince

Include windows.h.

EDIT: just too late. I wish I weren't a C++ newbie and had to look at how I solved the problem again. >_<

stahta01

Quote from: TDragon on June 05, 2007, 11:37:28 PM
Quote from: stahta01 on June 05, 2007, 11:34:22 PM
... I am guessing that I am missing an needed header.
That would be windows.h.

That was not enough, for sleep() to work. But, it was enough to get Sleep() to work.
Note, Google said minGW runtime had issues on sleep()
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Vlad417

stahta01: thanks, _sleep(); works for me perfectly, just how i wanted it.

Thanks everyone for your help! :D