Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Vlad417 on June 05, 2007, 07:49:06 pm

Title: Sleep() function errors
Post by: Vlad417 on June 05, 2007, 07:49:06 pm
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?
Title: Re: Sleep() function errors
Post by: darthdespotism on June 05, 2007, 08:56:16 pm
What compiler do you use?
Title: Re: Sleep() function errors
Post by: Vlad417 on June 05, 2007, 09:13:13 pm
GNU GCC
Title: Re: Sleep() function errors
Post by: raph on June 05, 2007, 09:23:24 pm
Please post the exact error message.
Title: Re: Sleep() function errors
Post by: patlecat on June 05, 2007, 10:46:42 pm
I've just compiled a program with Sleep() using GCC4.2 and CB 4051, it works perfectly well (under WinXP-SP2).
Title: Re: Sleep() function errors
Post by: Vlad417 on June 05, 2007, 10:53:03 pm
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+
Title: Re: Sleep() function errors
Post by: stahta01 on June 05, 2007, 11:34:22 pm
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

Code
#include <iostream>

using namespace std;

int main()
{
cout << "Going to Sleep!" << endl;
    _sleep(10000); // time in milliseconds
cout << "Hello world!" << endl;
return 0;
}
Title: Re: Sleep() function errors
Post by: TDragon on June 05, 2007, 11:37:28 pm
... I am guessing that I am missing an needed header.
That would be windows.h.
Title: Re: Sleep() function errors
Post by: DaVince on June 05, 2007, 11:40:38 pm
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. >_<
Title: Re: Sleep() function errors
Post by: stahta01 on June 05, 2007, 11:52:25 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()
Title: Re: Sleep() function errors
Post by: Vlad417 on June 05, 2007, 11:54:55 pm
stahta01: thanks, _sleep(); works for me perfectly, just how i wanted it.

Thanks everyone for your help! :D