BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
586 stars 165 forks source link

error: ‘reverse’ is not a member of ‘std’ #377

Closed hangingman closed 3 years ago

hangingman commented 3 years ago

On C++ backend, generated codes should add #include <algorithm>

This is my output logs during building bnfc generated C++ code

make
g++ -g --ansi -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unneeded-internal-declaration -c Absyn.C
g++ -g --ansi -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unneeded-internal-declaration -c Parser.C
Nask.y: In function ‘int nask_parse(yyscan_t, YYSTYPE*)’:
Nask.y:440:27: error: ‘reverse’ is not a member of ‘std’
  440 | Program : ListStmt { std::reverse($1->begin(),$1->end()) ;$$ = new Prog($1); result->program_ = $$; }
andreasabel commented 3 years ago

Apple clang version 11.0.0 (clang-1100.0.33.17) does not need this, but clang isn't always faithful to the standard.

Which version of g++ do you have? What does g++ --version print?

andreasabel commented 3 years ago

I can reproduce the problem with c++-11 (Homebrew GCC 11.2.0) 11.2.0.

andreasabel commented 3 years ago

On C++ backend, generated codes should add #include <algorithm>

This was the case until BNFC-2.9.1, so it is a regression I introduced when unifying the bison backends.

hangingman commented 3 years ago

@andreasabel Great, thank you !

hangingman commented 3 years ago

FYI my g++ version

$ g++ --version
g++ (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.