Skip to content

Commit 096b75d

Browse files
Fix warning on non-MSVC compilers.
Some Microsoft's specific #pragma were left in the code. They causes the following errors to be printed: ``` /tmp/antlr4/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp:1351:9: warning: unknown pragma ignored [-Wunknown-pragmas] may be unsafe. Consider using _dupenv_s instead. ^ /tmp/antlr4/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp:1361:9: warning: unknown pragma ignored [-Wunknown-pragmas] ``` This patch removes the #pragma macros and uses the matching compiler definition only on MSVC compiler.
1 parent f68c47a commit 096b75d

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

runtime/Cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if(WITH_DEMO)
6666
endif(WITH_DEMO)
6767

6868
if(MSVC_VERSION)
69-
set(MY_CXX_WARNING_FLAGS " /W4")
69+
set(MY_CXX_WARNING_FLAGS " /W4 /wd4996")
7070
else()
7171
set(MY_CXX_WARNING_FLAGS " -Wall -pedantic -W")
7272
endif()

runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,8 +1348,6 @@ Parser* ParserATNSimulator::getParser() {
13481348
return parser;
13491349
}
13501350

1351-
#pragma warning (disable:4996) // 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead.
1352-
13531351
bool ParserATNSimulator::getLrLoopSetting() {
13541352
char *var = std::getenv("TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT");
13551353
if (var == nullptr)
@@ -1358,8 +1356,6 @@ bool ParserATNSimulator::getLrLoopSetting() {
13581356
return value == "true" || value == "1";
13591357
}
13601358

1361-
#pragma warning (default:4996)
1362-
13631359
void ParserATNSimulator::InitializeInstanceFields() {
13641360
_mode = PredictionMode::LL;
13651361
_startIndex = 0;

0 commit comments

Comments
 (0)