Skip to content

Commit

Permalink
Fix for opencv#8105 (compiling with mingw32)
Browse files Browse the repository at this point in the history
fix for opencv#8105, compilation issue with mingw32 (in
google/googletest#721 a similar issue was solved and the reason was
described as MinGW defines _CRITICAL_SECTION and _RTL_CRITICAL_SECTION
as two separate (equivalent) structs, instead of using typedef)
  • Loading branch information
msk-repo01 committed Feb 2, 2017
1 parent ece3fac commit 9a1835c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions modules/ts/include/opencv2/ts/ts_gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,16 @@
# include <io.h>
# endif
// In order to avoid having to include <windows.h>, use forward declaration
// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
struct _RTL_CRITICAL_SECTION;
# if GTEST_OS_WINDOWS_MINGW
// MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
// separate (equivalent) structs, instead of using typedef
typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# else
// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# endif
#else
// This assumes that non-Windows OSes provide unistd.h. For OSes where this
// is not the case, we need to include headers that provide the functions
Expand Down Expand Up @@ -3057,7 +3063,7 @@ class GTEST_API_ Mutex {
// by the linker.
MutexType type_;
long critical_section_init_phase_; // NOLINT
_RTL_CRITICAL_SECTION* critical_section_;
GTEST_CRITICAL_SECTION* critical_section_;

GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
};
Expand Down

0 comments on commit 9a1835c

Please sign in to comment.