1

cppunit で qt プロジェクトをテストしようとしています。テスト プロジェクトは MFC を使用します。Visual Studio 2010 を使用しています。

私はqtライブラリ、dllを含め、テストしたいcppファイルをコンパイルするためのプリプロセッサ定義を追加するなど、プロジェクト設定に他の変更を加えました。しかし、この cpp ファイルをコンパイルすると、qt ヘッダー ファイルにある多くの構文エラーが発生します。コンパイル出力を以下に示します。

1>------ Build started: Project: my_tests, Configuration: Debug Win32 ------
1>cl : Command line warning D9025: overriding '/ZI' with '/Zi'
1>cl : Command line warning D9025: overriding '/GS' with '/GS-'
1>cl : Command line warning D9025: overriding '/Zc:wchar_t' with '/Zc:wchar_t-'
1>  CSetting.cpp
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qiodevice.h(247): error C2143: syntax error : missing ')' before 'constant'
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qiodevice.h(247): error C2143: syntax error : missing ';' before 'constant'
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qiodevice.h(247): error C2805: binary 'operator <<' has too few parameters
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qiodevice.h(247): error C2059: syntax error : ')'
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(160): error C2143: syntax error : missing ')' before 'constant'
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(160): error C2143: syntax error : missing ';' before 'constant'
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(160): error C2805: binary 'operator <<' has too few parameters
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(160): error C2988: unrecognizable template declaration/definition
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(160): error C2059: syntax error : 'constant'
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(160): error C2065: 'T' : undeclared identifier
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(160): error C2059: syntax error : ')'
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(178): error C2065: 'T' : undeclared identifier
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(180): error C2143: syntax error : missing ';' before '{'
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(180): error C2447: '{' : missing function header (old-style formal list?)
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(190): error C2143: syntax error : missing ')' before 'constant'
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(190): error C2143: syntax error : missing ';' before 'constant'
1>c:\qt\4.8.2\include\qtcore\../../src/corelib/io/qdebug.h(190): fatal error C1903: unable to recover from previous error(s); stopping compilation

これらのエラーで私を助けてください..

4

2 に答える 2

3

QT 4.8.x 以前を使用している必要があります。QT 5.x より前のすべてのバージョンは、

/Zc:wchar_t- 

(つまり、WChar_t を組み込み型として扱わないことを意味します)。これは、MFC、BOOST、または CUDA ライブラリと互換性がありません。フラグが変更された QT 5.x に切り替える必要があります。

/Zc:wchar_t

(最後に「マイナス」なし)-このようにコンパイルされます(彼らはこれを欠陥と見なしました)。

または、ソース ファイルで変更して、/Zc:wchar_t で古いバージョンをコンパイルします。

QTSRC\mkspecs\win32-msvc2010\qmake.conf
于 2013-06-14T19:52:11.800 に答える
1

推測することしかできませんが、クラス定義の後の最後のセミコロンまたは任意の時点で閉じ括弧が欠落している場合、この種のエラーが発生することがあります。

class XXX
{
};  // <- this one could be missing

CSettings.cpp で、QIODevice または QDebug の直前に含めるファイルを確認します。これは通常、問題のあるクラスです (CSettings.h の可能性があります)。

于 2012-08-17T09:31:58.273 に答える