Repository navigation
Build fails with gcc 11 / C++20 #1007
Copy link
Copy link
Closed
Description
Problem
Compiler error when including node.h with NAPI_VERSION=8:
napi.h:2477:60: error: expected unqualified-id before ‘)’ token
2477 | TypedThreadSafeFunction<ContextType, DataType, CallJs>();
| ^
/home/adiletkutmanov/Development/lauda_measurement_napi/node_modules/node-addon-api/napi.h:2479:33: error: expected ‘)’ before ‘tsFunctionValue’
2479 | napi_threadsafe_function tsFunctionValue);
| ^~~~~~~~~~~~~~~~
| )
/home/adiletkutmanov/Development/lauda_measurement_napi/node_modules/node-addon-api/napi.h:2478:59: note: to match this ‘(’
2478 | TypedThreadSafeFunction<ContextType, DataType, CallJs>(
| ^
In file included from /home/adiletkutmanov/Development/lauda_measurement_napi/node_modules/node-addon-api/napi.h:2725,
from /home/adiletkutmanov/Development/lauda_measurement_napi/src/lauda_measurement.cpp:1:
/home/adiletkutmanov/Development/lauda_measurement_napi/node_modules/node-addon-api/napi-inl.h:4764:8: error: no declaration matches ‘Napi::TypedThreadSafeFunction<ContextType, DataType, CallJs>::TypedThreadSafeFunction()’
4764 | inline TypedThreadSafeFunction<ContextType, DataType, CallJs>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/adiletkutmanov/Development/lauda_measurement_napi/node_modules/node-addon-api/napi-inl.h:4764:8: note: no functions named ‘Napi::TypedThreadSafeFunction<ContextType, DataType, CallJs>::TypedThreadSafeFunction()’
In file included from /home/adiletkutmanov/Development/lauda_measurement_napi/src/lauda_measurement.cpp:1:
/home/adiletkutmanov/Development/lauda_measurement_napi/node_modules/node-addon-api/napi.h:2347:9: note: ‘class Napi::TypedThreadSafeFunction<ContextType, DataType, CallJs>’ defined here
2347 | class TypedThreadSafeFunction {
| ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/adiletkutmanov/Development/lauda_measurement_napi/node_modules/node-addon-api/napi.h:2725,
from /home/adiletkutmanov/Development/lauda_measurement_napi/src/lauda_measurement.cpp:1:
/home/adiletkutmanov/Development/lauda_measurement_napi/node_modules/node-addon-api/napi-inl.h:4771:8: error: no declaration matches ‘Napi::TypedThreadSafeFunction<ContextType, DataType, CallJs>::TypedThreadSafeFunction(napi_threadsafe_function)’
4771 | inline TypedThreadSafeFunction<ContextType, DataType, CallJs>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/adiletkutmanov/Development/lauda_measurement_napi/node_modules/node-addon-api/napi-inl.h:4771:8: note: no functions named ‘Napi::TypedThreadSafeFunction<ContextType, DataType, CallJs>::TypedThreadSafeFunction(napi_threadsafe_function)’
In file included from /home/adiletkutmanov/Development/lauda_measurement_napi/src/lauda_measurement.cpp:1:
/home/adiletkutmanov/Development/lauda_measurement_napi/node_modules/node-addon-api/napi.h:2347:9: note: ‘class Napi::TypedThreadSafeFunction<ContextType, DataType, CallJs>’ defined here
2347 | class TypedThreadSafeFunction {
| ^~~~~~~~~~~~~~~~~~~~~~~
Workarounds:
- Use gcc 11 with c++17
- Use gcc 10 with c++20
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
KevinEady commentedon Jun 3, 2021
Hi @urp ,
I am able to replicate this issue the example in the readme.
Start container on gcc-11.1:
And run these commands:
I have noticed that using c++20 on my Mac (Apple clang version 12.0.0 (clang-1200.0.32.29)) does work. Not sure exactly how to proceed. We can discuss in the Node-API weekly meeting
cc: @mhdawson
richardlau commentedon Jun 3, 2021
FWIW C++20 support in gcc 11 is marked experimental: https://gcc.gnu.org/onlinedocs/gcc-11.1.0/gcc/C-Dialect-Options.html#C-Dialect-Options
KevinEady commentedon Jun 10, 2021
Thanks @richardlau for the insight! I am in the process of reporting the bug to GCC compiler team, currently waiting account creation.
@urp, unfortunately I think we will have to go with "known incompatibility" until GCC updates their compiler; since other c++20 compilers work, it is strictly an issue with GCC.
I will keep this issue open until I can link the GCC bug report in this ticket and our setup documentation page.
Thanks, Kevin
doc: add g++11 incompatibility with c++20
src: fix gcc-11 c++20 compilation
KevinEady commentedon Jun 11, 2021
This issue will be fixed when the associated PR is merged.
Thanks for reporting!
Edit: Please see the not-a-bug bug report comment for more information.
src: fix gcc-11 c++20 compilation
src: fix gcc-11 c++20 compilation
src: fix gcc-11 c++20 compilation
src: fix gcc-11 c++20 compilation
src: fix gcc-11 c++20 compilation
src: fix gcc-11 c++20 compilation