c/c++开发分享DEV-C ++中的编译器错误

我编译了以下代码,在我的C代码中使用#include 声明,我在DEV-C ++中遇到以下编译器错误。 我想编译器中应该有一些选项来解决这个问题。 有人可以帮助解决这个问题。

以下是我的示例代码,它取自MSDN网站:

#include #include void ErrorExit(LPTSTR lpszFunction) { // Retrieve the system error message for the last-error code LPVOID lpMsgBuf; LPVOID lpDisplayBuf; DWORD dw = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); // Display the error message and exit the process lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, (lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 40) * sizeof(TCHAR)); StringCchPrintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR), TEXT(\"%s failed with error %d: %s\"), lpszFunction, dw, lpMsgBuf); MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT(\"Error\"), MB_OK); LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); ExitProcess(dw); } void main() { // Generate an error if(!GetProcessId(NULL)) ErrorExit(TEXT(\"GetProcessId\")); }

大量错误中的错误示例。

154 26 C:Documents and Settingsmkumar@hubinoDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] expected \'=\', \',\', \';\', \'asm\' or \'__attribute__\' before \'char\' 155 26 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] expected \'=\', \',\', \';\', \'asm\' or \'__attribute__\' before \'const\' 156 1 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'__nullterminated\' 156 33 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] expected \'=\', \',\', \';\', \'asm\' or \'__attribute__\' before \'*\' token 157 26 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] expected \'=\', \',\', \';\', \'asm\' or \'__attribute__\' before \'const\' 158 26 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] expected \'=\', \',\', \';\', \'asm\' or \'__attribute__\' before \'const\' 164 38 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] expected \'=\', \',\', \';\', \'asm\' or \'__attribute__\' before \'const\' 165 38 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] expected \'=\', \',\', \';\', \'asm\' or \'__attribute__\' before \'const\' 166 38 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] expected \'=\', \',\', \';\', \'asm\' or \'__attribute__\' before \'const\' 173 10 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'STRSAFE_PCNZCH\' 174 10 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'__in_range\' 175 15 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'__deref_out_range\' 179 10 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'STRSAFE_PCNZWCH\' 180 10 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'__in_range\' 181 15 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'__deref_out_range\' 193 5 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'__deref_in_opt_out\' 194 17 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'__deref_out_range\' 200 5 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'__deref_in_opt_out\' 201 17 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'__deref_out_range\' 207 30 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'STRSAFE_PCNZCH\' 213 30 C:Documents and SettingsmkumarDesktopDEVCTEST-install-Driver-DifxTO-DOstrsafe.h [Error] unknown type name \'STRSAFE_LPCSTR\' continues.......

我收到上述错误的strsafe.h文件的一部分:

// // These typedefs are used in places where the string is guaranteed to // be null terminated. // typedef __nullterminated char* STRSAFE_LPSTR; typedef __nullterminated const char* STRSAFE_LPCSTR; typedef __nullterminated wchar_t* STRSAFE_LPWSTR; typedef __nullterminated const wchar_t* STRSAFE_LPCWSTR; typedef __nullterminated const wchar_t UNALIGNED* STRSAFE_LPCUWSTR; // // These typedefs are used in places where the string is NOT guaranteed to // be null terminated. // typedef __possibly_notnullterminated const char* STRSAFE_PCNZCH; typedef __possibly_notnullterminated const wchar_t* STRSAFE_PCNZWCH; typedef __possibly_notnullterminated const wchar_t UNALIGNED* STRSAFE_PCUNZWCH; // prototypes for the worker functions STRSAFEWORKERAPI StringLengthWorkerA( __in STRSAFE_PCNZCH psz, __in __in_range(<=, STRSAFE_MAX_CCH) size_t cchMax, __out_opt __deref_out_range(<, cchMax) size_t* pcchLength); STRSAFEWORKERAPI StringLengthWorkerW( __in STRSAFE_PCNZWCH psz, __in __in_range(<=, STRSAFE_MAX_CCH) size_t cchMax, __out_opt __deref_out_range(<, cchMax) size_t* pcchLength); #ifdef ALIGNMENT_MACHINE STRSAFEWORKERAPI UnalignedStringLengthWorkerW( __in STRSAFE_PCUNZWCH psz, __in __in_range(<=, STRSAFE_MAX_CCH) size_t cchMax, __out_opt __deref_out_range(<, cchMax) size_t* pcchLength); #endif // ALIGNMENT_MACHINE STRSAFEWORKERAPI StringExValidateSrcA( __deref_in_opt_out STRSAFE_LPCSTR* ppszSrc, __inout_opt __deref_out_range(<, cchMax) size_t* pcchToRead, __in const size_t cchMax, __in DWORD dwFlags);

__nullterminated,__ out_opt,__ in,__ in_opt和其他此类单词是Microsoft特定的关键字。 当你使用gcc时,你可以将它们定义为空的宏

#define __in #define __deref_out_range(A,B) ... and so on

在包含之前插入这些定义。

或者评论建议避免使用

编辑:

MinGW(来自http://equation.com的 x64版本)只需一个简单的命令就可以安静地编译上面的代码(即使使用strsafe.h ):

gcc -c Test.cpp -o Test.exe -lstdc++

以上就是c/c++开发分享DEV-C ++中的编译器错误相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注(猴子技术宅)。

本站无法对海量内容真伪性鉴别,请勿相信本站任何号码,邮件,站外网址等信息,如有需要,请自行甄别。版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至net@163.com举报,一经查实,本站将立刻删除。
(0)
上一篇 2022年8月25日 上午8:51
下一篇 2022年8月25日 上午9:03

相关推荐

  • 亚丁湾星门事件是什么情况 事件起因是啥

    亚丁湾星门事件是什么? 亚丁湾是地震。不过被传成星际之门。原因不祥!!! 星门事件的事件起因 2010年11月14号开始至15号上午11时,亚丁湾连续发生62次地震。其中吉布提海岸…

    2022年11月22日
  • 历史上的陈登有何才能?刘备是如何错过这位人才的呢?

      四大名著之中,三国演义描绘的是东汉末年的一幅画卷。下面好多多分享小编为大家带来详细的文章介绍。   《三国志·魏书·陈登传》:   君有国士之名,今天下大乱,帝主失所,望君忧国…

    2022年12月5日
  • kimoji是什么意思(kimoji是什么意思)

    您好,今天帅帅来为大家解答以上的问题。kimoji是什么意思,kimoji是什么意思相信很多小伙伴还不知道,现在让我们一起来看看吧! 1、1.如果是感叹句,就是:気持ちいい → き…

    2023年11月13日
  • iskin(关于iskin的介绍)

    大家好,今天生男来为大家解答以上的问题。iskin,关于iskin的介绍很多人还不知道,现在让我们一起来看看吧! 1、iSkin是以电子科技融合当代时尚元素结合的国际知名时尚设计品…

    2023年12月10日
  • excel07表格线

    excel07表格线 Excel07表格线是微软推出的Excel07软件的一个重要功能,它可以帮助用户更加直观、明了的查看、处理表格数据。Excel07表格线实际上是一种网格线,它…

    2023年8月15日
  • 中国亿元资产家庭(中国亿万论坛)

    您好,今天帅帅来为大家解答以上的问题。中国亿元资产家庭,中国亿万论坛相信很多小伙伴还不知道,现在让我们一起来看看吧! 1、网页链接这个吗。 本文就为大家分享到这里,希望小伙伴们会喜…

    2024年3月8日
  • 一级大检察官什么意思(一级大检察官什么级别)

    您好,今天帅帅来为大家解答以上的问题。一级大检察官什么意思,一级大检察官什么级别相信很多小伙伴还不知道,现在让我们一起来看看吧! 1、检察官等级设下列四等十二级:(一)首席大检察官…

    2023年1月14日
  • 伦敦奥运会体操(关于伦敦奥运会体操的介绍)

    大家好,今天生男来为大家解答以上的问题。伦敦奥运会体操,关于伦敦奥运会体操的介绍很多人还不知道,现在让我们一起来看看吧! 1、男子自由体操,是第29届奥运会比赛项目之一。 2、其成…

    2024年3月9日
  • 公元1年是什么朝代 是中国哪一年?

    公元01年是什么年代? 公元01年就是汉朝时期的西汉时期.当时正是王莽新政时期.不过在25年就被刘秀讨伐了. 公元1年是鸡年,公元1999年是啥年呢 (1999-1)/12=166…

    2022年11月24日
  • 重庆直辖市成立的历史背景(重庆直辖市成立时间)

    您好,今天帅帅来为大家解答以上的问题。重庆直辖市成立的历史背景,重庆直辖市成立时间相信很多小伙伴还不知道,现在让我们一起来看看吧! 1、1997年3月14日,第八届中国人大五次会议…

    2023年12月2日
  • 2021年32岁属什么生肖配对(2021年32岁属什么生肖)

    您好,今天帅帅来为大家解答以上的问题。2021年32岁属什么生肖配对,2021年32岁属什么生肖相信很多小伙伴还不知道,现在让我们一起来看看吧! 1、2021年30岁应该属于:生肖…

    2024年1月8日
  • 高丽参(高丽参的功效与作用和副作用)

    高丽参是朝鲜半岛上出产的一种人参。高丽参自古就有“一根高丽参如一串宝石”和“百草之王”的说法。高丽参含有34种人参皂苷成分远高于花旗参(13种)和三七参(15种)。另外人参皂甙Ra、Rf、Rg3、Rh2为高丽参独有成分。下面就来说说高丽参的功效、高丽参的作用以及高丽参的副作用。

    2022年5月27日
  • 蹲式马桶结构图直冲式(蹲式马桶结构图)

    您好,今天帅帅来为大家解答以上的问题。蹲式马桶结构图直冲式,蹲式马桶结构图相信很多小伙伴还不知道,现在让我们一起来看看吧! 1、蹲式马桶一体成型,在一端的凸起前挡、中央凹陷的长槽、…

    2024年3月13日
  • 什么是团队协作精神(如何做到团队协作,发扬团队协作精神)

    所谓团队精神,是指团队成员为了团队利益与目标而相互协作的作风,共同承担集体责任,齐心协力,汇聚在一起,形成一股强大的力量,成为一个强有力的集体。大家都知道 “拔河”运动,它是一种最能体现团队精神的运动,每个人都必须付出100%的努力,心朝一处想、劲朝一处使,紧密配合、互相支撑,才能形成一股强大的力量,势不可挡,战胜对方。

    2022年10月28日 投稿
  • 寥怎么读(寥)

    您好,今天帅帅来为大家解答以上的问题。寥怎么读,寥相信很多小伙伴还不知道,现在让我们一起来看看吧! 1、一、读音上来说廖的读音是liào,寥的读音是liáo。 2、二、从字形来看,…

    2023年10月20日

发表回复

登录后才能评论