плоские буферы — невозможно скомпилировать с помощью cygwin

#cmake #flatbuffers

#cmake #плоские буферы

Вопрос:

Я пытаюсь скомпилировать плоские буферы с помощью cygwin.

Вот что я делаю:

 git clone https://github.com/google/flatbuffers.git amp;amp; cd ./flatbuffers
  

Чем:

 cmake .
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c  .exe
-- Check for working CXX compiler: /usr/bin/c  .exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for strtof_l
-- Looking for strtof_l - not found
-- Looking for strtoull_l
-- Looking for strtoull_l - not found
-- `tests/monster_test.fbs`: add generation of C   code with '--no-includes;--gen-compare'
-- `tests/monster_test.fbs`: add generation of binary (.bfbs) schema
-- `tests/namespace_test/namespace_test1.fbs`: add generation of C   code with '--no-includes;--gen-compare'
-- `tests/namespace_test/namespace_test2.fbs`: add generation of C   code with '--no-includes;--gen-compare'
-- `tests/union_vector/union_vector.fbs`: add generation of C   code with '--no-includes;--gen-compare'
-- `tests/optional_scalars.fbs`: add generation of C   code with '--no-includes;--gen-compare'
-- `tests/native_type_test.fbs`: add generation of C   code with ''
-- `tests/arrays_test.fbs`: add generation of C   code with '--scoped-enums;--gen-compare'
-- `tests/arrays_test.fbs`: add generation of binary (.bfbs) schema
-- `tests/monster_test.fbs`: add generation of C   embedded binary schema code with '--no-includes;--gen-compare'
-- `tests/monster_extra.fbs`: add generation of C   code with '--no-includes;--gen-compare'
-- `samples/monster.fbs`: add generation of C   code with '--no-includes;--gen-compare'
-- `samples/monster.fbs`: add generation of binary (.bfbs) schema
Proceeding with version: 1.12.0.177
-- Configuring done
-- Generating done
-- Build files have been written to: /home/Vivas/flatbuffers
  

И когда я запускаю:

 $ make
Scanning dependencies of target flatbuffers
[  1%] Building CXX object CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o
[  2%] Building CXX object CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o
[  3%] Building CXX object CMakeFiles/flatbuffers.dir/src/reflection.cpp.o
[  4%] Building CXX object CMakeFiles/flatbuffers.dir/src/util.cpp.o
[  5%] Linking CXX static library libflatbuffers.a
[  5%] Built target flatbuffers
Scanning dependencies of target flatc
[  6%] Building CXX object CMakeFiles/flatc.dir/src/idl_parser.cpp.o
[  7%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o
[  9%] Building CXX object CMakeFiles/flatc.dir/src/reflection.cpp.o
[ 10%] Building CXX object CMakeFiles/flatc.dir/src/util.cpp.o
[ 11%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o
[ 12%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_csharp.cpp.o
[ 13%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_dart.cpp.o
[ 14%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_kotlin.cpp.o
[ 15%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o
[ 17%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_java.cpp.o
[ 18%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_js_ts.cpp.o
[ 19%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o
[ 20%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o
[ 21%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_lobster.cpp.o
[ 22%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_lua.cpp.o
[ 23%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_rust.cpp.o
[ 25%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o
[ 26%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o
[ 27%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_json_schema.cpp.o
[ 28%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_swift.cpp.o
[ 29%] Building CXX object CMakeFiles/flatc.dir/src/flatc.cpp.o
[ 30%] Building CXX object CMakeFiles/flatc.dir/src/flatc_main.cpp.o
[ 31%] Building CXX object CMakeFiles/flatc.dir/src/code_generators.cpp.o
[ 32%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o
[ 34%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o
[ 35%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/java_generator.cc.o
[ 36%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/python_generator.cc.o
[ 37%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/swift_generator.cc.o
[ 38%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/ts_generator.cc.o
[ 39%] Linking CXX executable flatc.exe
[ 39%] Built target flatc
Scanning dependencies of target generated_code
[ 40%] Run generation: 'samples/monster.bfbs'
[ 42%] Run generation: 'tests/monster_test_generated.h'
[ 43%] Run generation: 'tests/monster_test.bfbs'
[ 44%] Run generation: 'tests/namespace_test/namespace_test1_generated.h'
[ 45%] Run generation: 'tests/namespace_test/namespace_test2_generated.h'
[ 46%] Run generation: 'tests/union_vector/union_vector_generated.h'
[ 47%] Run generation: 'tests/optional_scalars_generated.h'
[ 48%] Run generation: 'tests/native_type_test_generated.h'
[ 50%] Run generation: 'tests/arrays_test_generated.h'
[ 51%] Run generation: 'tests/arrays_test.bfbs'
[ 52%] Run generation: 'tests/monster_test_bfbs_generated.h'
[ 53%] Run generation: 'tests/monster_extra_generated.h'
[ 54%] Run generation: 'samples/monster_generated.h'
[ 55%] All generated files were updated.
[ 55%] Built target generated_code
Scanning dependencies of target flatsamplebfbs
[ 56%] Building CXX object CMakeFiles/flatsamplebfbs.dir/src/idl_parser.cpp.o
[ 57%] Building CXX object CMakeFiles/flatsamplebfbs.dir/src/idl_gen_text.cpp.o
[ 59%] Building CXX object CMakeFiles/flatsamplebfbs.dir/src/reflection.cpp.o
[ 60%] Building CXX object CMakeFiles/flatsamplebfbs.dir/src/util.cpp.o
[ 61%] Building CXX object CMakeFiles/flatsamplebfbs.dir/samples/sample_bfbs.cpp.o
[ 62%] Linking CXX executable flatsamplebfbs.exe
[ 63%] Built target flatsamplebfbs
Scanning dependencies of target flatsampletext
[ 64%] Building CXX object CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o
[ 65%] Building CXX object CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o
[ 67%] Building CXX object CMakeFiles/flatsampletext.dir/src/reflection.cpp.o
[ 68%] Building CXX object CMakeFiles/flatsampletext.dir/src/util.cpp.o
[ 69%] Building CXX object CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o
[ 70%] Linking CXX executable flatsampletext.exe
[ 71%] Built target flatsampletext
Scanning dependencies of target flathash
[ 72%] Building CXX object CMakeFiles/flathash.dir/src/flathash.cpp.o
[ 73%] Linking CXX executable flathash.exe
[ 73%] Built target flathash
Scanning dependencies of target flattests
[ 75%] Building CXX object CMakeFiles/flattests.dir/src/idl_parser.cpp.o
[ 76%] Building CXX object CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o
[ 77%] Building CXX object CMakeFiles/flattests.dir/src/reflection.cpp.o
[ 78%] Building CXX object CMakeFiles/flattests.dir/src/util.cpp.o
[ 79%] Building CXX object CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o
[ 80%] Building CXX object CMakeFiles/flattests.dir/tests/test.cpp.o
/home/Vivas/flatbuffers/tests/test.cpp:66:19: error: ‘const auto infinityf’ redeclared as different kind of entity
   66 | static const auto infinityf = std::numeric_limits<float>::infinity();
      |                   ^~~~~~~~~
In file included from /usr/lib/gcc/x86_64-pc-cygwin/10/include/c  /cmath:45,
                 from /home/Vivas/flatbuffers/tests/test.cpp:16:
/usr/include/math.h:398:14: note: previous declaration ‘float infinityf()’
  398 | extern float infinityf (void);
      |              ^~~~~~~~~
In file included from /home/Vivas/flatbuffers/tests/test.cpp:45:
/home/Vivas/flatbuffers/tests/test.cpp: In function ‘void TestMonsterExtraFloats()’:
/home/Vivas/flatbuffers/tests/test.cpp:702:25: error: wrong type argument to unary minus
  702 |   TEST_EQ(is_quiet_nan(-infinityf), false);
      |                         ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:34: note: in definition of macro ‘TEST_EQ’
   19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
      |                                  ^~~
/home/Vivas/flatbuffers/tests/test.cpp:731:29: error: wrong type argument to unary minus
  731 |   TEST_EQ(def_extra->f3(), -infinityf);
      |                             ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
   19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
      |                                       ^~~
/home/Vivas/flatbuffers/tests/test.cpp:762:25: error: wrong type argument to unary minus
  762 |   TEST_EQ(extra->f3(), -infinityf);
      |                         ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
   19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
      |                                       ^~~
/home/Vivas/flatbuffers/tests/test.cpp:770:35: error: wrong type argument to unary minus
  770 |   TEST_EQ(extra->fvec()->Get(1), -infinityf);
      |                                   ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
   19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
      |                                       ^~~
/home/Vivas/flatbuffers/tests/test.cpp: In function ‘void ValidFloatTest()’:
/home/Vivas/flatbuffers/tests/test.cpp:1971:60: error: wrong type argument to unary minus
 1971 |   TEST_EQ(TestValue<float>("{ y:-3.4029e 38 }", "float"), -infinityf);
      |                                                            ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
   19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
      |                                       ^~~
/home/Vivas/flatbuffers/tests/test.cpp:2015:53: error: wrong type argument to unary minus
 2015 |   TEST_EQ(TestValue<float>("{ y:-inf }", "float"), -infinityf);
      |                                                     ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
   19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
      |                                       ^~~
/home/Vivas/flatbuffers/tests/test.cpp:2017:53: error: wrong type argument to unary minus
 2017 |   TEST_EQ(TestValue<float>(nullptr, "float=-inf"), -infinityf);
      |                                                     ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
   19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
      |                                       ^~~
/home/Vivas/flatbuffers/tests/test_assert.h: In instantiation of ‘void TestEq(T, U, const char*, const char*, int, const char*) [with T = float; U = float (*)()]’:
/home/Vivas/flatbuffers/tests/test.cpp:730:3:   required from here
/home/Vivas/flatbuffers/tests/test_assert.h:92:7: error: invalid ‘static_cast’ from type ‘float’ to type ‘float (*)()’
   92 |   if (static_cast<U>(expval) != val) {
      |       ^~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/flattests.dir/build.make:184: CMakeFiles/flattests.dir/tests/test.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:247: CMakeFiles/flattests.dir/all] Error 2
make: *** [Makefile:161: all] Error 2
  

Почему это так, и как я могу это исправить?

Ответ №1:

Проще всего было бы переименовать infinityf (at tests/test.cpp:66:19 ) и его использование во что-то другое. Если это приведет к компиляции, откройте PR на https://github.com/google/flatbuffers с вашими изменениями.

Похоже, что это противоречит вещам, объявленным в cmath заголовке. Я не уверен, почему это происходит с cygwin, а не на другой платформе, которую мы создаем для gcc?

Также обратите внимание, что это в тестах, которые вам не обязательно создавать. Вызов CMake с -DFLATBUFFERS_BUILD_TESTS=OFF помощью, вероятно, также будет работать.