Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macros for pthreads lead to inconsitency on MinGW #752

Closed
truschival opened this issue Apr 8, 2016 · 2 comments
Closed

Macros for pthreads lead to inconsitency on MinGW #752

truschival opened this issue Apr 8, 2016 · 2 comments

Comments

@truschival
Copy link

Compilng on MinGW gcc 4.8.0 the class Autohandle form googletest/include/gtest/internal/gtest-ports.h is not defined.

Error:

[ 22%] Building CXX object googletest-build/googlemock/CMakeFiles/gmock_main.dir/**/googletest/src/gtest-all.cc.obj
cd /d C:\tmp\libtransmog_gcc_cov\googletest-build\googlemock && J:\toolchain\Qt\Qt5.1.0\Tools\mingw48_32\bin\g++.exe -O3 -DNDEBUG @CMakeFiles/gmock_main.dir/includes_CXX.rsp -Wall -Wshadow -DGTEST_HAS_PTHREAD=1 -fexceptions -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -std=gnu++11 -o CMakeFiles\gmock_main.dir**\googletest\src\gtest-all.cc.obj -c C:\tmp\libtransmog_gcc_cov\googletest-src\googletest\src\gtest-all.cc

In file included from C:/tmp/libtransmog_gcc_cov/googletest-src/googletest/include/gtest/internal/gtest-internal.h:40:0,
from C:/tmp/libtransmog_gcc_cov/googletest-src/googletest/include/gtest/gtest.h:58,
from C:\tmp\libtransmog_gcc_cov\googletest-src\googletest\src\gtest-all.cc:39:

C:/tmp/libtransmog_gcc_cov/googletest-src/googletest/include/gtest/internal/gtest-port.h:1782:3: error: 'AutoHandle' does not name a type
AutoHandle thread_;

My analysis so far:
I understand that posix thread support is not the best and not even available in all runtime libraries of MinGW. When explicity configuring using cmake -Dgtest_disable_pthreads=On all works fine.

Unfortunately MinGW distributes libpthread and therefore googletest/cmake/internal_utils.cmake finds pthread and sets -DGTEST_HAS_PTHREAD=1 (line 123).
This is however inconsistent with the preprocessor macros in the source in googletest/include/gtest/internal/gtest-port.h
I have not yet figured out the chain of macros that leads to the fact that Autohandle is in an inactive preprocessor #ifdef #elif construct but ThreadWithParamBase is enabled.

I am not confident to fix the preprocessor macros without breaking the build on other platforms/compilers. I could "fix" it on cmake-level quickly but the inconsistency in the code would remain.

** Environment MinGW distributed with QT 5.1 **
Target: i686-w64-mingw32
gcc version 4.8.0 (rev2, Built by MinGW-builds project)

@dvdjg
Copy link

dvdjg commented Aug 1, 2016

Hello @truschival ! I did a different analysis.
It was only needed to complement some #ifdefs.
I wrote a comment about it:
#606 (comment)

@KindDragon
Copy link
Contributor

Please close this issue as duplicate of #606

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants