elixir-lang / tree-sitter-elixir

Elixir grammar for tree-sitter
https://elixir-lang.org/tree-sitter-elixir
Apache License 2.0
245 stars 24 forks source link

Make C++ source compatible with older standards #7

Closed jonatanklosko closed 2 years ago

jonatanklosko commented 2 years ago

Closes #6.

Tested by explicitly compiling with -std=c++98.

➜  tree-sitter-elixir git:(main) gcc -o tmp/parser.so -I./src src/parser.c src/scanner.cc -shared -fPIC -std=c++98
cc1: warning: command-line option ‘-std=c++98’ is valid for C++/ObjC++ but not for C
src/scanner.cc: In function ‘bool {anonymous}::is_token_end(int32_t)’:
src/scanner.cc:110:33: warning: range-based ‘for’ loops only available with ‘-std=c++11’ or ‘-std=gnu++11’
  110 |   for (const char& terminator : token_terminators) {
      |                                 ^~~~~~~~~~~~~~~~~
src/scanner.cc:110:33: error: forming reference to reference type ‘const char (&)[27]’
src/scanner.cc: In function ‘void* {anonymous}::tree_sitter_elixir_external_scanner_create()’:
src/scanner.cc:601:12: error: ‘nullptr’ was not declared in this scope
  601 |     return nullptr;
      |            ^~~~~~~

After the change, it compiles fine.

jonatanklosko commented 2 years ago

@alappe could you try running tree-sitter generate && tree-sitter test on this branch, just to ensure it fixes it for you? :)

alappe commented 2 years ago

It does, thank you very much!

jonatanklosko commented 2 years ago

Awesome, thanks for checking!