首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何正确地包含atlbase.h

如何正确地包含atlbase.h
EN

Stack Overflow用户
提问于 2014-02-16 03:10:15
回答 1查看 3.8K关注 0票数 3

我试图使用一些提供给我的库代码,这些代码需要一些ATL功能,但我经常会遇到如下错误:

代码语言:javascript
运行
复制
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atltransactionmanager.h(396): error C2039: 'CreateFile' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atltransactionmanager.h(427): error C2039: 'DeleteFile' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atltransactionmanager.h(460): error C2039: 'MoveFile' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6517): error C2039: 'GetModuleFileName' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6517): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6591): error C2039: 'GetModuleFileName' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6591): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\statreg.h(481): error C3861: 'FindResource': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\statreg.h(674): error C3861: 'CreateFile': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6676): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6762): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(6885): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlbase.h(7228): error C3861: 'GetModuleFileName': identifier not found
1>c:\program files (x86)\microsoft sdks\speech\v11.0\include\sphelper.h(1246): error C2039: 'LoadLibrary' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft sdks\speech\v11.0\include\sphelper.h(1246): error C3861: 'LoadLibrary': identifier not found

我确实在我自己的机器上安装了它,并且原始项目本身没有问题地编译。出于保密的原因,我不能共享原始项目本身,但我可以共享它的编译标志(对格式设置不当表示歉意):

代码语言:javascript
运行
复制
/Yc"stdafx.h" /GS /analyze- /W3 /wd"4995" /Zc:wchar_t /ZI /Gm /Od /Fd"Debug\vc110.pdb" /fp:precise /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "DLL_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\KinectCommonBridge.pch" 

这里是我的(请尽管忽略openFrameworks相关的包含,我正试图使项目尽可能接近他们的设置,以便更容易地翻译给用户):

代码语言:javascript
运行
复制
/Yc"stdafx.h" /GS /TP /analyze- /W3 /Zc:wchar_t /I"..\..\..\libs\openFrameworks" /I"..\..\..\libs\openFrameworks\graphics" /I"..\..\..\libs\openFrameworks\app" /I"..\..\..\libs\openFrameworks\sound" /I"..\..\..\libs\openFrameworks\utils" /I"..\..\..\libs\openFrameworks\communication" /I"..\..\..\libs\openFrameworks\video" /I"..\..\..\libs\openFrameworks\types" /I"..\..\..\libs\openFrameworks\math" /I"..\..\..\libs\openFrameworks\3d" /I"..\..\..\libs\openFrameworks\gl" /I"..\..\..\libs\openFrameworks\events" /I"..\..\..\libs\glut\include" /I"..\..\..\libs\rtAudio\include" /I"..\..\..\libs\quicktime\include" /I"..\..\..\libs\freetype\include" /I"..\..\..\libs\freetype\include\freetype2" /I"..\..\..\libs\freeImage\include" /I"..\..\..\libs\fmodex\include" /I"..\..\..\libs\videoInput\include" /I"..\..\..\libs\glew\include\" /I"..\..\..\libs\glu\include" /I"..\..\..\libs\tess2\include" /I"..\..\..\libs\cairo\include\cairo" /I"..\..\..\libs\poco\include" /I"..\..\..\libs\glfw\include" /I"..\..\..\libs\openssl\include" /I"..\..\..\addons" /I"src" /I"..\..\..\addons\ofxKinectCommonBridge\src" /I"..\..\..\addons\ofxKinectCommonBridge\libs\KinectCommonBridge\include" /I"..\..\..\addons\ofxGui\src" /I"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include" /ZI /Gm /Od /Fd"obj\Debug\vc110.pdb" /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "POCO_STATIC" /D "CAIRO_WIN32_STATIC_BUILD" /D "DISABLE_SOME_FLOATING_POINT" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"obj\Debug\" /EHsc /nologo /Fo"obj\Debug\" /Fp"obj\Debug\SpeechExample_debug.pch" 

我不太熟悉ATL或它的使用,但在我看来,正确地包含这个文件并不那么困难。我研究了这两个项目,在任何包含或编译器标志中都找不到任何根本不同的地方。谢谢您的指导,如果有帮助的话,我很乐意提供更多的信息。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-16 08:10:54

::CreateFile是用WinBase.h定义的。因此,在包含WinBase.h atlbase.h之前,您应该包括Windows.h

我无法确定为什么在atlbase.h中没有这样做。但是,您可以定义在项目中使用的Windows头文件。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21806803

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档