Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix c++ error caused by c99 static array size #698

Closed
wants to merge 1 commit into from

Conversation

twinstar6980
Copy link

Due to the changes in PR 593, quickjs-ng cannot be compiled in C++ mode.

C++ does not support the T val[static n] array syntax, which will cause the compiler to report an error: error: static array size is a C99 feature, not permitted in C++(clang).

This commit avoids entering the static n branch in C++ mode.

@saghul
Copy link
Contributor

saghul commented Nov 17, 2024

How come our c++ CI doesn't catch this? How are you building your software?

@bnoordhuis
Copy link
Contributor

@twinstar6980 you can include quickjs.h in a C++ file but quickjs itself must be compiled as C, not C++

@twinstar6980
Copy link
Author

The cpp file in my project references the cutils.h file, so it causes the error. For some reason, I referenced it in the project a long time ago.
cutils.h seems to be a private header. Inside quickjs, it will only work in C mode and will never trigger this error.

@bnoordhuis
Copy link
Contributor

Right, that explains it. I'll go ahead and close this.

@bnoordhuis bnoordhuis closed this Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants