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

C/C++ scanner: add #elifdef and #elifndef #4518

Open
delan opened this issue Apr 21, 2024 · 1 comment
Open

C/C++ scanner: add #elifdef and #elifndef #4518

delan opened this issue Apr 21, 2024 · 1 comment
Labels
c++23 Features new in the 2023 C++ Standard C23 Features new in the 2023 C Standard enhancement scanner

Comments

@delan
Copy link

delan commented Apr 21, 2024

C++23 introduces #elifdef and #elifdef in the preprocessor: https://en.cppreference.com/w/cpp/preprocessor/conditional

// Note that if a compiler does not support C++23's #elifdef/#elifndef
// directives then the "unexpected" block (see below) will be selected.
#ifdef CPU
    std::cout << "4: no1\n";
#elifdef GPU
    std::cout << "4: no2\n";
#elifndef RAM
    std::cout << "4: yes\n"; // expected block
#else
    std::cout << "4: no!\n"; // unexpectedly selects this block by skipping
                             // unknown directives and "jumping" directly
                             // from "#ifdef CPU" to this "#else" block
#endif
@mwichmann mwichmann changed the title C++ scanner: add #elifdef and #elifndef C/C++ scanner: add #elifdef and #elifndef Apr 21, 2024
@mwichmann mwichmann added c++23 Features new in the 2023 C++ Standard C23 Features new in the 2023 C Standard labels Apr 21, 2024
@mwichmann
Copy link
Collaborator

mwichmann commented Apr 21, 2024

Applies to C23 as well. For grins, here's the example from the C standard:

#ifdef __STDC__
#define TITLE "ISO C Compilation"
#elifndef __cplusplus
#define TITLE "Non-ISO C Compilation"
#else
/* C++ */
#define

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++23 Features new in the 2023 C++ Standard C23 Features new in the 2023 C Standard enhancement scanner
Projects
None yet
Development

No branches or pull requests

2 participants