最近在做项目时,需要将VS2017的代码整合进qtcreator项目中,遇到了一个奇怪的问题,代码如下:
.pro文件
LIBS += -L'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/atlmfc/lib/x64/' -latls
INCLUDEPATH += 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/atlmfc/include'
DEPENDPATH += 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/atlmfc/include'
.h文件(导致错误的vs .h文件)
#include<atlstr.h>
相关dll库我已经放在了和 .exe 同目录下
我直接把该 .h 文件加进了qtcreator项目中
运行之后,报了2500个错误,部分错误如下:
\atlmfc\include\atldef.h:669: error: expected constructor, destructor, or type conversion before '(' token#define ATLPREFAST_SUPPRESS(x) __pragma(warning(push)) __pragma(warning(disable: x)
\atlmfc\include\atldef.h:237: error: 'suppress' was not declared in this scope
#define ATLASSUME(expr) do { ATLASSERT(expr); Analysis_assume(!!(expr)); } __pragma(warning(suppress:4127)) while (0)
\atlmfc\include\atldef.h:237: error: expected ';' before 'while'
#define ATLASSUME(expr) do { ATLASSERT(expr); Analysis_assume(!!(expr)); } __pragma(warning(suppress:4127)) while (0)
\atlmfc\include\atldef.h:254: error: there are no arguments to 'warning' that depend on a template parameter, so a declaration of 'warning' must be available [-fpermissive] } __pragma(warning(suppress:4127)) while (0)
\atlmfc\include\atlcomcli.h:1621: error: 'bstrText' was not declared in this scope return (bstrText != NULL) ? true : false;
\atlmfc\include\atlbase.h:4792: error: expected ')' before '=' token __declspec(property(get = get_m_csStaticDataInit)) CRITICAL_SECTION m_csTypeInfoHolder;
错误类型基本就是这些,在不同的文件中重复的出现
我开始以为是编码格式的问题,然后我弄了一下,没有什么作用, 然后我在 qtcreator 中安装了 VS2017 的编译器,和一下无用的操作,结果错误莫名其妙的减少了一半,只剩下 1249 个, 错误类型还是那些。
希望各位能够给我解答疑惑,万分感谢!