You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
C++ STL backend: compilation error because of std::to_string #534
It seems that the code generated by the --cpp backend does not compile:
test.y: In function ‘void test_error(YYLTYPE*, yyscan_t, YYSTYPE*, const char*)’:
test.y:224:37: error: ‘to_string’ is not a member of ‘std’
224 | error_msg += " at line " + std::to_string(loc->first_line) +
| ^~~~~~~~~
test.y:224:37: note: ‘std::to_string’ is only available from C++17 onwards
test.y:225:37: error: ‘to_string’ is not a member of ‘std’
225 | ", column " + std::to_string(loc->first_column);
| ^~~~~~~~~
test.y:225:37: note: ‘std::to_string’ is only available from C++17 onwards
This problem only appears on BNFC 2.9.6.2 and earlier versions work normally.
Reproduction
Using BNFC 2.9.6.2, pick any valid test.cf definition and run
bnfc --cpp -m test.cf && make
Misc
The Makefile generated by the C++ backend uses --ansi for compilation, and std::to_string is invalid with it. And it seems to be introduced by #494 .
Also, I found the issue when I was running the bnfc-system-tests. It seems that this test is not enabled by default and lacks up-to-date running scripts. I am doing some minor improvements on it (still WIP), see Commelina@24acb54.
Activity
Fix BNFC#534: C++: avoid `std::to_string` for ansi compatibility
Fix BNFC#534: C++: avoid `std::to_string` for ansi compatibility
Fix BNFC#534: C++: avoid `std::to_string` for ansi compatibility
Fix BNFC#534: C++: avoid `std::to_string` for ansi compatibility