Author Topic: Sleep() function errors  (Read 34536 times)

Vlad417

  • Guest
Sleep() function errors
« 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?

Offline darthdespotism

  • Almost regular
  • **
  • Posts: 163
    • Coder's Nemesis
Re: Sleep() function errors
« Reply #1 on: June 05, 2007, 08:56:16 pm »
What compiler do you use?

Vlad417

  • Guest
Re: Sleep() function errors
« Reply #2 on: June 05, 2007, 09:13:13 pm »
GNU GCC

Offline raph

  • Almost regular
  • **
  • Posts: 242
Re: Sleep() function errors
« Reply #3 on: June 05, 2007, 09:23:24 pm »
Please post the exact error message.

Offline patlecat

  • Multiple posting newcomer
  • *
  • Posts: 62
Re: Sleep() function errors
« Reply #4 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).

Vlad417

  • Guest
Re: Sleep() function errors
« Reply #5 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+

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7699
    • My Best Post
Re: Sleep() function errors
« Reply #6 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;
}
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Sleep() function errors
« Reply #7 on: June 05, 2007, 11:37:28 pm »
... I am guessing that I am missing an needed header.
That would be windows.h.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline DaVince

  • Multiple posting newcomer
  • *
  • Posts: 11
    • DaVince's Website
Re: Sleep() function errors
« Reply #8 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. >_<

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7699
    • My Best Post
Re: Sleep() function errors
« Reply #9 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()
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Vlad417

  • Guest
Re: Sleep() function errors
« Reply #10 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