-
December 22nd, 2012, 11:09 PM
#1
#include <WinBase.h> errors: how to avoid?
I get a slew of syntax errors starting in line 243 of <WinBase.h>.
The compiler underscores such typedefs as ULONG_PTR, DWORD, PVOID and HANDLE among others.
Presumably, <winbase.h> has a prerequisite header file that it is not #include'g itself :-(.
What am I missing?
PS: I tried changing the order of #include <WinBase.h>, to no avail.
The code is....
Code:
#include "stdafx.h"
#include <stdlib.h>
#include <time.h> // for time()
#include <WinBase.h> // for sleep()
int _tmain(int argc, char* argv[])
{
time_t st, et;
st = time();
sleep(2000);
et = time();
printf("%ld\n%ld\n%ld\n", st, et, et-st);
done:
printf("press Enter to terminate");
getchar();
return 0;
}
"stdafx.h" is (as provided by Visual C++)....
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
"targetver.h" is (as provided by Visual C++)....
#pragma once
#include <SDKDDKVer.h>
Last edited by Marc G; December 26th, 2012 at 04:55 AM.
Reason: Added code tags
-
December 23rd, 2012, 12:41 AM
#2
Re: #include <WinBase.h> errors: how to avoid?
Originally Posted by joeu2004
I get a slew of syntax errors starting in line 243 of <WinBase.h>.
The compiler underscores such typedefs as ULONG_PTR, DWORD, PVOID and HANDLE among others.
You should include <windows.h>, and from there add any missing headers that are API-based. Trying to cherry-pick which "sub-header" to include, as you've done, isn't the way to go about this.
Regards,
Paul McKenzie
-
December 23rd, 2012, 02:09 AM
#3
Re: #include <WinBase.h> errors: how to avoid?
Originally Posted by Paul McKenzie
You should include <windows.h>, and from there add any missing headers that are API-based. Trying to cherry-pick which "sub-header" to include, as you've done, isn't the way to go about this.
Thanks. Including <windows.h> does eliminate the error.
As for cherry-picking, I was simply following the information in the sleep "man page" at http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx.
It states that the header file is WinBase.h on WinXP.
But in fact, including <windows.h> and even subsequently including <WinBase.h> does not provide the function prototype for sleep().
I'll post a separate question.
-
December 24th, 2012, 02:57 PM
#4
Re: #include <WinBase.h> errors: how to avoid?
From the "man page"
Syntax
C++
VOID WINAPI Sleep(
_In_ DWORD dwMilliseconds
);
It's not sleep, it's Sleep. C/C++ is case sensitive.
Best regards,
Igor
-
December 26th, 2012, 09:05 AM
#5
Re: #include <WinBase.h> errors: how to avoid?
Originally Posted by joeu2004
You have to read it all.
WinBase.h on Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008, and Windows Server 2008 R2 (include Windows.h);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|