2012-08-17 5 views
1

cppunit을 사용하여 qt 프로젝트를 테스트하려고합니다. 테스트 프로젝트는 MFC를 사용합니다. Visual Studio 2010을 사용 중입니다.qt 헤더 파일에서 컴파일 오류가 발생했습니다.

전 테스트 할 cpp 파일을 컴파일하기 위해 전 처리기 정의를 추가하는 등 프로젝트 설정에 qt 라이브러리, dll을 포함하고 다른 변경 사항을 포함 시켰습니다. 나는이 CPP 파일을 컴파일 할 때, 나는 Qt는 헤더 files..The 컴파일 출력에있는 구문 오류, 많은이 아래에 주어진다 얻을 :

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 

이러한 오류 제발 도와주세요 ..

답변

1

I 추측 할 수는 있지만 클래스 정의 후에 마지막 세미콜론을 누락하거나 어떤 점에서 닫는 대괄호를 빠뜨린 경우 이런 종류의 오류가 발생하는 경우가 있습니다. 당신의 CSettings.cpp에서

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

, 당신은 QIODevice 또는 QDebug 전에 직접 포함 파일에있는 확인합니다. 이것은 일반적으로 결함이있는 클래스입니다 (CSettings.h 일 수 있음)

+0

합니다. 모든 세미콜론과 대괄호가 제자리에 있습니다 .. – Hariprasad

+0

Qt 헤더 파일을 포함하기 전에 모든 cpp 파일에 StdAfx.h를 포함하고 있습니다 ... 문제의 원인이 무엇입니까 ..? 그런 경우 해결책이 될 수 있습니까? 다른 헤더 파일보다 먼저 StdAfx.h를 포함해야하기 때문에, 맞습니까? – Hariprasad

+0

흠 Qt include를 제거하고 다른 오류가 있는지 확인하십시오 (물론 "unknown symbol"을 제외하고) –

3

QT 4.8.x 또는 그 이전 버전을 사용해야합니다. QT 5.x의 이전 모든 버전은

/Zc:wchar_t- 

로 컴파일 (뜻 : 유형 내장으로 wchar_t를 취급하지 마십시오) MFC, 부스트 또는 CUDA 라이브러리와 호환되지이다. 당신은 QT 5.x를 전환해야하는 플래그 (끝 "마이너스"없이)

/Zc:wchar_t 

로 변경 - 그것은 이런 식으로 컴파일 (그들은 결함으로 이것을 고려).

또는/ZC와 이전 버전의 컴파일 : wchar_t를, 소스 파일을 변경하여 : 나는 CSettings.h 포함한 모든 headerfiles을 확인했다

QTSRC\mkspecs\win32-msvc2010\qmake.conf 
관련 문제