py-tree-sitter icon indicating copy to clipboard operation
py-tree-sitter copied to clipboard

Use c++17 for non-c files

Open aksh-at opened this issue 4 years ago • 7 comments

https://github.com/tree-sitter/tree-sitter-haskell uses c++17 language features, so needs to be built with that flag.

Test output:

...........
----------------------------------------------------------------------
Ran 11 tests in 0.012s

OK

aksh-at avatar Apr 04 '21 02:04 aksh-at

Blocking this on https://github.com/tree-sitter/tree-sitter-haskell/pull/38 for Windows support in CI

lunixbochs avatar Jun 05 '21 08:06 lunixbochs

Don't C++17 features mean commands like tree-sitter test and tree-sitter parse won't work on macOS? ref https://github.com/tree-sitter/tree-sitter/issues/1246

ahelwer avatar Aug 25 '21 20:08 ahelwer

Probably. I think I mentioned in the Haskell thread, tree sitter probably needs a better standardized approach to building C++ parsers.

lunixbochs avatar Aug 25 '21 20:08 lunixbochs

This is no longer needed for tree-sitter-haskell, as that external scanner has been rewritten in plain C.

maxbrunsfeld avatar Jan 18 '22 23:01 maxbrunsfeld

ah perfect. let me get the test-haskell branch up to date with that then close this PR, this issue is where I got stuck previously

lunixbochs avatar Jan 19 '22 00:01 lunixbochs

Haskell looks to be failing on Windows Python 3.5 runner even with the new C parser: https://github.com/tree-sitter/py-tree-sitter/runs/5104795690?check_suite_focus=true

lunixbochs avatar Feb 08 '22 06:02 lunixbochs

The Haskell scanner uses restrict, which MSVC only supports in C11 or C17 mode (and not the weird C89+extensions that is the default), but py-tree-sitter compiles .c files without flags on Windows.

narpfel avatar Feb 08 '22 22:02 narpfel

I would like to see this change land.

On macOS, when trying to compile 'scanner.cc', the /usr/bin/cc compiler is invoked. That is:

$ cc --version Apple clang version 13.1.6 (clang-1316.0.21.2.5) Target: x86_64-apple-darwin22.3.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

And this compiler defaults to not supporting C++ at all.

My particular example scanner.cc uses C++17 features, so this patch would be ideal.

dneto0 avatar Feb 02 '23 19:02 dneto0

Alternately, it would be sufficient to be able to pass compiler flags down through the interface.

dneto0 avatar Feb 02 '23 20:02 dneto0

Haskell's scanner is now back in C, and no we do not want to encourage using modern standards/features in a scanner, it is just not needed.

amaanq avatar Aug 25 '23 22:08 amaanq