| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4987 人关注过本帖
标题:Dev C++编译包含windows.h头文件的程序时出错
只看楼主 加入收藏
svjh
Rank: 1
等 级:等待验证会员
帖 子:47
专家分:0
注 册:2007-11-27
收藏
 问题点数:0 回复次数:7 
Dev C++编译包含windows.h头文件的程序时出错
我用Dev C++的32位图形界面工程建立程序,
然后当我include<windows.h>头文件时,便开始出错`
如果把#include<windows.h>这一句去掉,又可以编译了

我是用Dev C++来写的,出错时的编译日志如下:

程序代码:
编译器: Default compiler
Building Makefile: "F:\FILES\WorkStation\CSC\test\test\upload\Makefile.win"
执行  make...
make.exe -f "F:\FILES\WorkStation\CSC\test\test\upload\Makefile.win" all
gcc.exe -c main.c -o main.o -I"E:/Dev-Cpp/include"    -ansi -traditional-cppIn file included from E:/Dev-Cpp/include/windows.h:48,
                 from main.c:5:
E:/Dev-Cpp/include/windef.h:263: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:263: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:264: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:264: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:265: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:265: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:266: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:266: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:267: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:267: error: syntax error before '{' tokenE:/Dev-Cpp/include/windef.h:268: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:268: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:269: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:269: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:270: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:270: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:271: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:271: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:272: error: syntax error at '##' tokenE:/Dev-Cpp/include/windef.h:272: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:273: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:273: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:276: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:276: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:278: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:278: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:279: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:279: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:281: error: syntax error before '*' token
E:/Dev-Cpp/include/windef.h:282: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:282: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:283: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:283: error: syntax error before '{' tokenE:/Dev-Cpp/include/windef.h:284: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:284: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:285: error: syntax error before "HMODULE"
E:/Dev-Cpp/include/windef.h:286: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:286: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:287: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:287: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:288: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:288: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:289: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:289: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:290: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:290: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:291: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:291: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:292: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:292: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:293: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:293: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:294: error: syntax error at '##' token
E:/Dev-Cpp/include/windef.h:294: error: syntax error before '{' token
E:/Dev-Cpp/include/windef.h:296: error: syntax error before "HCURSOR"In file included from E:/Dev-Cpp/include/windows.h:50,
                 from main.c:5:
E:/Dev-Cpp/include/winbase.h:1026: error: syntax error before "LPCTSTR"
E:/Dev-Cpp/include/winbase.h:1027: error: syntax error before "LPCTSTR"
E:/Dev-Cpp/include/winbase.h:1028: error: syntax error before "LPTSTR"
E:/Dev-Cpp/include/winbase.h:1040: error: syntax error before "LPSTR"



(中间一堆千字文,省略掉......具体请看附件)


E:/Dev-Cpp/include/ole2.h:85: error: syntax error before "int"
E:/Dev-Cpp/include/ole2.h:88: error: syntax error before "LPOLESTR"
E:/Dev-Cpp/include/ole2.h:104: error: syntax error before "LPSTGMEDIUM"
E:/Dev-Cpp/include/ole2.h:105: error: syntax error before "LPSTGMEDIUM"
make.exe: *** [main.o] Error 1执行结束




是因为windows.h头文件的缘故吗?
哪位朋友能来帮个忙呢``?

[[it] 本帖最后由 svjh 于 2008-7-28 00:20 编辑 [/it]]

程序源代码及编译日志.rar (10.43 KB)
搜索更多相关主题的帖子: 编译 windows 文件 
2008-07-28 00:18
sxn0508
Rank: 1
等 级:新手上路
帖 子:120
专家分:0
注 册:2008-1-24
收藏
得分:0 
你把main.c改成main.cpp试一下
2008-07-28 15:49
fxstudenting
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-7-28
收藏
得分:0 
这个问题我能帮你解答,去这个两博客其中的一个,把问题写到留言版上,我马上给你解答。
http://dlstudenting.
http://fxstudenting.blog.
或去这个QQ群:67030031
专业致力于解决各类编程问题,主要方向为JAVA/C/C++/VB/VC/LINUX/UNIX等各种疑难问题!
2008-07-28 16:55
svjh
Rank: 1
等 级:等待验证会员
帖 子:47
专家分:0
注 册:2007-11-27
收藏
得分:0 
[bo][un]fxstudenting[/un] 在 2008-7-28 16:55 的发言:[/bo]

这个问题我能帮你解答,去这个两博客其中的一个,把问题写到留言版上,我马上给你解答。
http://dlstudenting.
http://fxstudenting.blog.
或去这个QQ群:67030031
专业致力于解决各类编程问题,主 ...


这样的广告也能发出来?!
2008-07-28 18:43
svjh
Rank: 1
等 级:等待验证会员
帖 子:47
专家分:0
注 册:2007-11-27
收藏
得分:0 
[bo][un]sxn0508[/un] 在 2008-7-28 15:49 的发言:[/bo]

你把main.c改成main.cpp试一下


改为cpp后,出现这个问题:

程序代码:
编译器: Default compiler
Building Makefile: "F:\FILES\WorkStation\CSC\test\test\upload\Makefile.win"
执行  make...
make.exe -f "F:\FILES\WorkStation\CSC\test\test\upload\Makefile.win" all
gcc.exe -c main.cpp -o main.o -I"E:/Dev-Cpp/include"    -ansi -traditional-cpp

main.cpp: In function `int sysreg()':
main.cpp:17: error: `sleep' undeclared (first use this function)
main.cpp:17: error: (Each undeclared identifier is reported only once for each function it appears in.)

make.exe: *** [main.o] Error 1

执行结束
2008-07-28 18:46
svjh
Rank: 1
等 级:等待验证会员
帖 子:47
专家分:0
注 册:2007-11-27
收藏
得分:0 
是和API之间的兼容性问题吗`?
2008-07-29 18:04
flyue
Rank: 10Rank: 10Rank: 10
来 自:江南西道
等 级:贵宾
威 望:19
帖 子:3465
专家分:1563
注 册:2006-6-20
收藏
得分:0 
你用的是不是VC的Windows.h?

天之道,损有余而补不足.人之道则不然,损不足以奉有余.孰能有余以奉天下,唯有道者.
2008-07-29 18:15
svjh
Rank: 1
等 级:等待验证会员
帖 子:47
专家分:0
注 册:2007-11-27
收藏
得分:0 
[bo][un]flyue[/un] 在 2008-7-29 18:15 的发言:[/bo]

你用的是不是VC的Windows.h?


是Dev C++自带的Windows.h``
2008-07-29 18:27
快速回复:Dev C++编译包含windows.h头文件的程序时出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024255 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved