In pelles c windows.h doesn't compile
I'm using pelles c. when I compile this code:
#include <windows.h>
#include <stdio.h>
void main(void)
{
printf("Hello World");
}
I get this error:
D:\Program Files\PellesC\Include\Win\basetsd.h(53): error #2001: Syntax error: expected ';' but found 'INT64'.
D:\Program Files\PellesC\Include\Win\basetsd.h(53): warning #2099: Missing type specifier; assuming 'int'.
D:\Program Files\PellesC\Include\Win\basetsd.h(57): error #2120: Redeclaration of '__int64', previously declared at D:\Program Files\PellesC\Include\Win\basetsd.h(53); expected 'int' but found 'unsigned int'.
D:\Program Files\PellesC\Include\Win\basetsd.h(57): error #2001: Syntax error: expected ';' but found 'UINT64'.
D:\Program Files\PellesC\Include\Win\basetsd.h(57): wa开发者_开发百科rning #2099: Missing type specifier; assuming 'int'.
D:\Program Files\PellesC\Include\Win\winnt.h(558): fatal error #1014: #error: "No target architecture".
thanks for your help.
In order to use windows.h
in PellesC
you have to go to:
- Project -> Project Options -> Compiler
- Check: Enable Microsoft Extensions
You're missing some #define
s which other compilers (e.g. Visual Studio) always define. They provide essential information about the processor architecture, the OS version, the SDK version etc.
It's probably best to look up the Microsoft documentation about what macros their compiler defines and do the same.
This page could be a good starting point.
- Initialize your program by using
int main(void)
and notvoid main(void)
- You are missing your return statement of
return(0);
just before your last bracket. You must include this or you will get a syntax error because your program does not know when to stop running.
Then do the following
- From your pull down menu bar select
Project
then scroll down and select `Project Options. - Select the
Compiler
tab and make sure that theCalling conv:
box has_cdecl
selected. - Click on the
linker
tab and make sure that in thesubsystem
box the type is set toConsole
.
Try building it again and see what happens!
精彩评论