Posix regex not found. Other regex produces compilation errors
- Dominant language
- C++
- Stars
- 39.6k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
This is for googletest release 1.11.0
Compiling on MacOs Catalina
Trying to compile this sample code:
```
#include "gtest/gtest.h"
// Demonstrate some basic assertions.
TEST(HelloTest, BasicAssertions) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world");
// Expect equality.
EXPECT_EQ(7 * 6, 42);
}
```
Initially produced these errors:
```
/Users/jsaremi/install_folder/include/gtest/internal/gtest-port.h:929:3: error: unknown type name 'regex_t'
regex_t full_regex_; // For FullMatch().
^
/Users/jsaremi/install_folder/include/gtest/internal/gtest-port.h:930:3: error: unknown type name 'regex_t'
regex_t partial_regex_; // For PartialMatch().
^
```
I tried disabling the POSIX option by including these lines prior to "gtest.h". That did not work:
```
#define GTEST_USES_SIMPLE_RE 1
#define GTEST_USES_POSIX_RE 0
```
then I tried the following:
```
#define GTEST_USES_PCRE 1
#define GTEST_USES_SIMPLE_RE 1
#include "gtest/gtest.h"
```
This time I got the following errors:
```
In file included from /Users/jsaremi/src/install_folder/main/src/framework/tests/GTestSample.cpp:18:
In file included from /Users/jsaremi/install_folder/include/gtest/gtest.h:64:
In file included from /Users/jsaremi/install_folder/include/gtest/gtest-death-test.h:41:
In file included from /Users/jsaremi/install_folder/include/gtest/internal/gtest-death-test-internal.h:39:
/Users/jsaremi/install_folder/include/gtest/gtest-matchers.h:798:29: error: unknown type name 'RE'
MatchesRegexMatcher(const RE* regex, bool full_match)
^
/Users/jsaremi/install_folder/include/gtest/gtest-matchers.h:842:31: error: unknown type name 'RE'
const std::shared_ptr regex_;
^
/Users/jsaremi/install_folder/include/gtest/gtest-matchers.h:826:26: error: use of undeclared identifier 'RE'
return full_match_ ? RE::FullMatch(s2, *regex_)
^
/Users/jsaremi/install_folder/include/gtest/gtest-matchers.h:827:26: error: use of undeclared identifier 'RE'
: RE::PartialMatch(s2, *regex_);
^
```
What is the rightway of ensuring that Regex code compiles?
Thanks
Contributor guide
Assessment
This issue has not been assessed yet.