adamritter / fastgron

High-performance JSON to GRON (greppable, flattened JSON) converter
MIT License
592 stars 10 forks source link

Compile error: parse_path.cpp: use of undeclared identifier ‘sort’ #11

Closed kseistrup closed 1 year ago

kseistrup commented 1 year ago

This relates to commit 2a85e6a0534b56eceb70d779ef87531a8b6f48b5

Neither clang, nor gcc will compile fastgron:

» # SHELL=/usr/bin/fish
» # Let's try with clang first:
» cmake -B build -DCMAKE_CXX_COMPILER=/usr/bin/clang++; and cmake --build build
-- The CXX compiler identification is Clang 15.0.7
[…]
[ 77%] Building CXX object CMakeFiles/fastgron.dir/src/parse_path.cpp.o
[ 88%] Building CXX object CMakeFiles/fastgron.dir/extern/simdjson/simdjson.cpp.o
…/fastgron/src/parse_path.cpp:84:9: error: use of undeclared identifier 'sort'
        sort(accessors.object_accessors.begin(), accessors.object_accessors.end(), [](const ObjectAccessor &a, const ObjectAccessor &b)
        ^
1 error generated.
» # Now let's try gcc:
» rm -rf build
» cmake -B build -DCMAKE_CXX_COMPILER=/usr/bin/g++; and cmake --build build
-- The CXX compiler identification is GNU 13.1.1
[…]
[ 77%] Building CXX object CMakeFiles/fastgron.dir/src/parse_path.cpp.o
[ 88%] Building CXX object CMakeFiles/fastgron.dir/extern/simdjson/simdjson.cpp.o
…/fastgron/src/parse_path.cpp: In member function ‘ObjectAccessors Parser::parseObjectAccessors()’:
…/fastgron/src/parse_path.cpp:84:9: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   84 |         sort(accessors.object_accessors.begin(), accessors.object_accessors.end(), [](const ObjectAccessor &a, const ObjectAccessor &b)
      |         ^~~~
      |         short
» echo $CXXFLAGS
-march=x86-64 -mtune=native -O2 -pipe -flto -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS
» echo $LDFLAGS
-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
» uname -av
Linux mqnav 6.3.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 21 Jun 2023 20:46:20 +0000 x86_64 GNU/Linux
adamritter commented 1 year ago

Thanks,

I don't know why some compilers need #include and others not, but I added the change and released it as v0.6.2.

On Sat, Jul 1, 2023 at 9:41 AM Klaus Alexander Seistrup < @.***> wrote:

This relates to commit 2a85e6a https://github.com/adamritter/fastgron/commit/2a85e6a0534b56eceb70d779ef87531a8b6f48b5

Neither clang, nor gcc will compile fastgron:

» # SHELL=/usr/bin/fish » # Let's try with clang first: » cmake -B build -DCMAKE_CXX_COMPILER=/usr/bin/clang++; and cmake --build build -- The CXX compiler identification is Clang 15.0.7 […] [ 77%] Building CXX object CMakeFiles/fastgron.dir/src/parse_path.cpp.o [ 88%] Building CXX object CMakeFiles/fastgron.dir/extern/simdjson/simdjson.cpp.o …/fastgron/src/parse_path.cpp:84:9: error: use of undeclared identifier 'sort' sort(accessors.object_accessors.begin(), accessors.object_accessors.end(), [](const ObjectAccessor &a, const ObjectAccessor &b) ^ 1 error generated. » # Now let's try gcc: » rm -rf build » cmake -B build -DCMAKE_CXX_COMPILER=/usr/bin/g++; and cmake --build build -- The CXX compiler identification is GNU 13.1.1 […] [ 77%] Building CXX object CMakeFiles/fastgron.dir/src/parse_path.cpp.o [ 88%] Building CXX object CMakeFiles/fastgron.dir/extern/simdjson/simdjson.cpp.o …/fastgron/src/parse_path.cpp: In member function ‘ObjectAccessors Parser::parseObjectAccessors()’: …/fastgron/src/parse_path.cpp:84:9: error: ‘sort’ was not declared in this scope; did you mean ‘short’? 84 | sort(accessors.object_accessors.begin(), accessors.object_accessors.end(), [](const ObjectAccessor &a, const ObjectAccessor &b) | ^~~~ | short » echo $CXXFLAGS -march=x86-64 -mtune=native -O2 -pipe -flto -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS » echo $LDFLAGS -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now » uname -av Linux mqnav 6.3.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 21 Jun 2023 20:46:20 +0000 x86_64 GNU/Linux

— Reply to this email directly, view it on GitHub https://github.com/adamritter/fastgron/issues/11, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN5SWAB4YFIPAZWNB5XUGB3XN7IDFANCNFSM6AAAAAAZ2UN2MM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

kseistrup commented 1 year ago

Thanks for fixing it so swiftly.