开发者

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 #defines 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.


  1. Initialize your program by using int main(void) and not void main(void)
  2. 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

  1. From your pull down menu bar select Project then scroll down and select `Project Options.
  2. Select the Compiler tab and make sure that the Calling conv: box has _cdecl selected.
  3. Click on the linker tab and make sure that in the subsystem box the type is set to Console.

Try building it again and see what happens!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜