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

C11 keywords support #6022

Closed
SPAstef opened this issue Aug 25, 2020 · 8 comments
Closed

C11 keywords support #6022

SPAstef opened this issue Aug 25, 2020 · 8 comments

Comments

@SPAstef
Copy link

SPAstef commented Aug 25, 2020

In the current version of the extension, support for C11 keywords such as _Alignas, _Alignof, _Generic, etc. is quite weird:

  1. C11 keywords with arguments are not colored like keywords, but like "function calls" by the semantic colorizer engine.
  2. Most C11 keywords are not suggested by intellisense, although they are evaluated by the "floating snippet".
  3. The keyword _Atomic is actually suggested by intellisense, but it is treated like plain text, so colorization is again wrong.

The screenshot below shows all the problems I've encountered.
Settings that might take part in this:
"C_Cpp.default.cStandard" = "c18"
"C_Cpp.default.intelliSenseMode": "clang-x64" (but it is the same with gcc-x64)

Schermata da 2020-08-25 18-42-11

@Colengms
Copy link
Collaborator

Hi @SPAstef . The C/C++ Extension provides semantic colorization. However, these are not semantically detected identifiers (unless implemented as macros), these are language keywords. Colorization for language keywords comes from VS Code and it's TextMate language grammar. That grammar for C/C++ is contributed by this repro: https://github.com/jeff-hykin/cpp-textmate-grammar That grammar is also available in the "Better C++ Syntax" extension, and is often updated more frequently than updates are contributed to VS Code. I'd suggest opening issues for any uncolored keywords in that repo.

If I understand correctly, language keywords are also added by VS Code, not the extension.

@sean-mcmanus
Copy link
Collaborator

I think proper handling of C keywords is being tracked by jeff-hykin/better-cpp-syntax#70 .

@SPAstef
Copy link
Author

SPAstef commented Aug 25, 2020

Hi, and thanks for the reply!
So you're saying that basically nothing of this has to do with the C/C++ extension, but rather VScode itself or Textmate, so I should report this issue to them, right? Do you think the extension you mentioned is likely to fix these issues (granted, it's not something one can't live without! Just I think it would be nice having full support for C11 (considering it's almost 10 years old already, 😅)

@SPAstef
Copy link
Author

SPAstef commented Aug 25, 2020

I think proper handling of C keywords is being tracked by jeff-hykin/better-cpp-syntax#70 .

Ok I'll give it a look, thanks

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Aug 25, 2020

"_Alignof" was intentionally omitted from our keyword completion, because the recommended style is to use
#include <stdalign.h> with alignas or alignof, although we should remove alignof and alignas as keywords, because they're duplicates of the macros in those headers (and not keywords in C).

@SPAstef
Copy link
Author

SPAstef commented Aug 25, 2020

I read the issue you linked. Mixing C and C++ IMHO is never a good thing, especially considering the completely different pace at which C++ moves and the orders of magnitude of complexity in its grammar. It's almost like mixing Java and JavaScript grammars since they have a similar name...

@sean-mcmanus
Copy link
Collaborator

We fixed the issue with "alignas" etc. appearing as keywords in C with https://github.com/microsoft/vscode-cpptools/releases/tag/0.30.0-insiders4 . "_Alignof" etc. aren't added because using the macros defined in stdalign.h etc. is recommended instead (those macros will appear in completion after the headers are added).

@Colengms
Copy link
Collaborator

Closing this, as we don't generally track issues with VS Code's TextMate grammar in this repo. If there is a detail here that I missed that can be addressed by the C/C++ Extension, please let me know. :)

@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants