google / google/googletest

GCC 8.2.0 gives >error: pasting "GMOCK_PP_IDENTITY" and "(" does not give a valid preprocessing token<

Open
#2,367 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.6k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

On my Windows machine, using GCC 8.2.0 from [nuwen.net distro](https://nuwen.net/mingw.html) and CMake I'm getting compilation errors.

The configuration part goes well:
```
C:\build\adambadura-googletest\MinGW>cmake -G "MinGW Makefiles" -Dgtest_build_tests=ON -Dgtest_build_samples=ON -Dgmock_build_tests=ON "C:\Users\abadura\Dropbox\Projekty\adambadura-googletest" .
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python37_64/python.exe (found version "3.7.3")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/build/adambadura-googletest/MinGW
```

However, the building part fails:
```
C:\build\adambadura-googletest\MinGW>cmake --build .
Scanning dependencies of target gtest
[ 1%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj
[ 1%] Linking CXX static library ..\lib\libgtest.a
[ 1%] Built target gtest
Scanning dependencies of target gmock
[ 1%] Building CXX object googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.obj
[ 2%] Linking CXX static library ..\lib\libgmock.a
[ 2%] Built target gmock
Scanning dependencies of target gmock_main
[ 2%] Building CXX object googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.obj
[ 3%] Linking CXX static library ..\lib\libgmock_main.a
[ 3%] Built target gmock_main
Scanning dependencies of target gmock_leak_test_
[ 4%] Building CXX object googlemock/CMakeFiles/gmock_leak_test_.dir/test/gmock_leak_test_.cc.obj
[ 4%] Linking CXX executable gmock_leak_test_.exe
[ 4%] Built target gmock_leak_test_
Scanning dependencies of target gmock_main_no_exception
[ 4%] Building CXX object googlemock/CMakeFiles/gmock_main_no_exception.dir/src/gmock_main.cc.obj
[ 5%] Linking CXX static library ..\lib\libgmock_main_no_exception.a
[ 5%] Built target gmock_main_no_exception
Scanning dependencies of target gmock-actions_test
[ 5%] Building CXX object googlemock/CMakeFiles/gmock-actions_test.dir/test/gmock-actions_test.cc.obj
[ 6%] Linking CXX executable gmock-actions_test.exe
[ 6%] Built target gmock-actions_test
Scanning dependencies of target gmock-cardinalities_test
[ 6%] Building CXX object googlemock/CMakeFiles/gmock-cardinalities_test.dir/test/gmock-cardinalities_test.cc.obj
[ 7%] Linking CXX executable gmock-cardinalities_test.exe
[ 7%] Built target gmock-cardinalities_test
Scanning dependencies of target gmock-port_test
[ 7%] Building CXX object googlemock/CMakeFiles/gmock-port_test.dir/test/gmock-port_test.cc.obj
[ 8%] Linking CXX executable gmock-port_test.exe
[ 8%] Built target gmock-port_test
Scanning dependencies of target gmock-generated-matchers_test
[ 9%] Building CXX object googlemock/CMakeFiles/gmock-generated-matchers_test.dir/test/gmock-generated-matchers_test.cc.obj
[ 9%] Linking CXX executable gmock-generated-matchers_test.exe
[ 9%] Built target gmock-generated-matchers_test
Scanning dependencies of target gmock-generated-function-mockers_test
[ 10%] Building CXX object googlemock/CMakeFiles/gmock-generated-function-mockers_test.dir/test/gmock-generated-function-mockers_test.cc.obj
[ 10%] Linking CXX executable gmock-generated-function-mockers_test.exe
[ 10%] Built target gmock-generated-function-mockers_test
Scanning dependencies of target gmock_test
[ 11%] Building CXX object googlemock/CMakeFiles/gmock_test.dir/test/gmock_test.cc.obj
[ 11%] Linking CXX executable gmock_test.exe
[ 11%] Built target gmock_test
Scanning dependencies of target gmock_ex_test
[ 12%] Building CXX object googlemock/CMakeFiles/gmock_ex_test.dir/test/gmock_ex_test.cc.obj
[ 12%] Linking CXX executable gmock_ex_test.exe
[ 12%] Built target gmock_ex_test
Scanning dependencies of target gmock-function-mocker_test
[ 12%] Building CXX object googlemock/CMakeFiles/gmock-function-mocker_test.dir/test/gmock-function-mocker_test.cc.obj
In file included from C:/Users/abadura/Dropbox/Projekty/adambadura-googletest/googlemock/include/gmock/gmock-function-mocker.h:40,
from C:/Users/abadura/Dropbox/Projekty/adambadura-googletest/googlemock/include/gmock/gmock.h:61,
from C:\Users\abadura\Dropbox\Projekty\adambadura-googletest\googlemock\test\gmock-function-mocker_test.cc:45:
C:\Users\abadura\Dropbox\Projekty\adambadura-googletest\googlemock\test\gmock-function-mocker_test.cc:163:3: error: pasting "GMOCK_PP_IDENTITY" and "(" does not give a valid preprocessing token
MOCK_METHOD(int, CTNullary, (), (Calltype(STDMETHODCALLTYPE)));
^~~~~~~~~~~
C:\Users\abadura\Dropbox\Projekty\adambadura-googletest\googlemock\test\gmock-function-mocker_test.cc:164:3: error: pasting "GMOCK_PP_IDENTITY" and "(" does not give a valid preprocessing token
MOCK_METHOD(bool, CTUnary, (int), (Calltype(STDMETHODCALLTYPE)));
^~~~~~~~~~~
C:\Users\abadura\Dropbox\Projekty\adambadura-googletest\googlemock\test\gmock-function-mocker_test.cc:165:3: error: pasting "GMOCK_PP_IDENTITY" and "(" does not give a valid preprocessing token
MOCK_METHOD(int, CTDecimal,
^~~~~~~~~~~
C:\Users\abadura\Dropbox\Projekty\adambadura-googletest\googlemock\test\gmock-function-mocker_test.cc:169:3: error: pasting "GMOCK_PP_IDENTITY" and "(" does not give a valid preprocessing token
MOCK_METHOD(char, CTConst, (int), (const, Calltype(STDMETHODCALLTYPE)));
^~~~~~~~~~~
C:\Users\abadura\Dropbox\Projekty\adambadura-googletest\googlemock\test\gmock-function-mocker_test.cc:170:3: error: pasting "GMOCK_PP_IDENTITY" and "(" does not give a valid preprocessing token
MOCK_METHOD((std::map), CTReturnTypeWithComma, (),
^~~~~~~~~~~
C:\Users\abadura\Dropbox\Projekty\adambadura-googletest\googlemock\test\gmock-function-mocker_test.cc:476:3: error: pasting "GMOCK_PP_IDENTITY" and "(" does not give a valid preprocessing token
MOCK_METHOD(void, Push, (const T& elem),
^~~~~~~~~~~
C:\Users\abadura\Dropbox\Projekty\adambadura-googletest\googlemock\test\gmock-function-mocker_test.cc:478:3: error: pasting "GMOCK_PP_IDENTITY" and "(" does not give a valid preprocessing token
MOCK_METHOD(void, Pop, (), (Calltype(STDMETHODCALLTYPE), override));
^~~~~~~~~~~
C:\Users\abadura\Dropbox\Projekty\adambadura-googletest\googlemock\test\gmock-function-mocker_test.cc:479:3: error: pasting "GMOCK_PP_IDENTITY" and "(" does not give a valid preprocessing token
MOCK_METHOD(int, GetSize, (), (Calltype(STDMETHODCALLTYPE), override, const));
^~~~~~~~~~~
C:\Users\abadura\Dropbox\Projekty\adambadura-googletest\googlemock\test\gmock-function-mocker_test.cc:480:3: error: pasting "GMOCK_PP_IDENTITY" and "(" does not give a valid preprocessing token
MOCK_METHOD(const T&, GetTop, (),
^~~~~~~~~~~
mingw32-make.exe[2]: *** [googlemock\CMakeFiles\gmock-function-mocker_test.dir\build.make:63: googlemock/CMakeFiles/gmock-function-mocker_test.dir/test/gmock-function-mocker_test.cc.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:567: googlemock/CMakeFiles/gmock-function-mocker_test.dir/all] Error 2
mingw32-make.exe: *** [Makefile:140: all] Error 2
```

The same code builds well with Visual C++ (at least under NMake generator). However, with VC some tests do not pass for reasons unknown to me (#2368).

Is this a known issue? Is it related to the Windows environment only?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the GCC 8.2.0 MinGW build failure while compiling googlemock/test/gmock-function-mocker_test.cc. Read googlemock/include/gmock/gmock-function-mocker.h and the failing MOCK_METHOD cases, then compare the behavior with the reported Visual C++ build. Done means the affected test target builds successfully with the reported configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.