2017-04-25 91 views
-2

我想在我的cpp單元測試用例中模擬第三方API調用。爲此,我使用VS2013中的Nuget pakage manager在我的項目中安裝了gmock 1.7.0。它在我的測試項目中添加了gmock-all.cc和gtest-all.cc。一旦我遵守它就沒有問題。只要我在我的cppunit測試用例中添加了#include「gmock \ gmock.h」,它會給我提供以下錯誤信息 -#include「gmock gmock.h」給編譯時錯誤

2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(893):error C2065:'lhs':未聲明的標識符 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \包括\ gtest \ internal \ gtest-internal.h(893):錯誤C2988:無法識別的模板聲明/定義 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(893):error C2059:語法錯誤:'const' 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(901):錯誤C2143:語法錯誤:缺少';' '{' 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(901):error C2447:'{':缺少函數頭(舊式正式列表?) 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(933):錯誤C2065:'from':未聲明的標識符 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(933):錯誤C2065 :'L':未聲明的標識符 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(933):error C2065:' to':未聲明的標識符 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(935):error C2182:'CopyArray' :非法使用'void' 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(935):錯誤C2433:'CopyArray':'內聯'不允許數據聲明 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(935):error C2365:'testing :: internal :: CopyArray':redefinition;以前的定義是'function' 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(935):error C2998:'int testing :: internal :: CopyArray':不能作爲模板定義

你能幫我擺脫這個嗎?

回答

0

我正在使用cpprest以及gmock。兩者之間都存在衝突,因此導致了這些錯誤。爲了擺脫這一點,我們需要包含_TURN_OFF_PLATFORM_STRING預處理器指令。

有關更多詳細信息,請參閱 Issue with CPP Rest and gmock