neslib/Chet

error: unknown type name 'bool'

Closed this issue · 4 comments

How to configure Chet if header uses bool type, but it does not define #include <stdbool.h>
For the example code:

struct IsLicense {
  bool is_licensed;
  char error[10];
};

Chet returns the following error:
error: unknown type name 'bool'

C doesn't have native support for bool. So the header file must include <stdbool.h> (or another include file that includes <stdbool.h>

After adding #include <stdbool.h> to the source code I get the following list of errors:

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\yvals_core.h:29:2: error: Error in C++ Standard Library usage
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\xkeycheck.h:54:2: error: The C++ Standard Library forbids macroizing the keyword "bool". Enable warning C4005 to find the forbidden define.
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\xkeycheck.h:234:2: error: The C++ Standard Library forbids macroizing the keyword "false". Enable warning C4005 to find the forbidden define.
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\xkeycheck.h:439:2: error: The C++ Standard Library forbids macroizing the keyword "true". Enable warning C4005 to find the forbidden define.
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\yvals_core.h:829:1: error: use of undeclared identifier 'EMIT'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstdint:21:1: error: unknown type name 'namespace'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstdint:21:1: error: expected ';' after top level declarator
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstdlib:23:62: error: expected function body after function declarator
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstdio:33:1: error: unknown type name 'namespace'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cstdio:33:1: error: expected ';' after top level declarator
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cwchar:22:1: error: unknown type name 'using'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cwchar:22:19: error: unexpected type name 'mbstate_t': expected expression
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cwchar:24:1: error: unknown type name 'namespace'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\cwchar:24:1: error: expected ';' after top level declarator
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\limits:37:1: error: unknown type name 'namespace'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\limits:37:1: error: expected ';' after top level declarator
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\yvals.h:346:1: error: unknown type name 'namespace'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\yvals.h:346:1: error: expected ';' after top level declarator
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\vcruntime_exception.h:28:5: error: unknown type name 'EMIT'

If I create a header file with the #include <stdbool.h> and your sample struct, it translates just fine.
The errors seems to indicate that the header files use C++ instead of C. Chet only works with C.

Thank you. I found that a few of headers use C++ code.