-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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++ invalid macro definitions with V1.9.7 and newer #9435
Comments
That project seems to be configured with another configuration provider. Are you able to create a repro that doesn't use that configuration provider? If you run C/C++: Log Diagnostics, does the output appear to show correct data being provided by the configuration provider? What does that error say in English? It sounds like it's saying the |
Hi @sean-mcmanus your guess is correct. The configuration provider is the extension "IAR For Visual Studio Code"(iar-vsc) from pluyckx. Without this it is actually not possible for me to create a working setup. The Error Massage in English: Command line error: Invalid macro definition: STDC_VERSION=199901L And here is the log file from C/C++: Log Diagnostics (Version 1.10.5): V1.10.5.txt |
later I completely deleted the defines for testing and looked at the error reactions of the different C/C++ versions with active IAR extension of pluyckx. C/C++: Log Diagnostics: -------- Diagnostics - 14.6.2022, 10:48:43 ------- Workspace parsing diagnostics ------- Error in English: Command line error: Invalid macro definition: _Pragma(x)= C/C++: Log Diagnostics: -------- Diagnostics - 14.6.2022, 10:47:08 ------- Workspace parsing diagnostics ------- Test summary: Does anyone have a guess where this error could come from? |
Hi @JulianMaV . It looks like our IntelliSense parser (which is based on EDG) is complaining about (any of) the following defines:
I can repro the issue by placing these directly in a simple I'll follow up with an IntelliSense engineer internally. It's unclear to me whether these defines should take precedence over |
Curiously, the issue only repros when using an
The defines provided (from the IAR compiler) do not indicate that it supports MSC extensions. If your environment is not intended to compile MSVC or Windows headers, you might want to contact the author of |
Hi, I am a developer on the This error seems to occur when the provider gives a conflicting definition of one of the macros you listed above. For |
Hi @HampusAdolfsson . I noticed that your custom configuration extension is providing the Could you check if you get acceptable IntelliSense behavior if your extension provides The 'invalid macro' errors are actually ignorable, and do not interfere with IntelliSense. The values you are providing should indeed be used. (The error is actually originating in code tries to specify values for these defines, and fails because they were already explicitly set by the configuration.) Another potential issue here is that the |
Hello each other, What can I do now to make these errors disappear until there is a solution? Is there an ignore list for errors, because working with constant error messages and red marks can be a bit annoying? How else can I help you to solve this error case? |
Hi @Colengms. I get this error regardless of the intellisenseMode, including with Even if the EDG version used by IAR compilers is upgraded, it is quite common for our users to use older compilers, so we cannot expect the compiler's EDG version to match what the intellisenseMode wants to define.
|
Hi @HampusAdolfsson . To clarify, this warning should not occur with a non-MSVC IntelliSenseMode. Could you please check again? Looking at the code, there is a flag that imposes a requirement on these defines, and that flag is specific to the MSVC mode, specific to the version of MSVC we are emulating, and specific to how we conform to C11 and C17. If not an MSVC mode, the flag that triggers this warning should not be set, and I am unable to repro the error message with non-MSVC IntelliSense modes. My suggestion would be to ensure you are not providing |
@Colengms |
I've created a minimal example here, with a very simple provider: |
Hi @HampusAdolfsson . The problem is that IntelliSense is itself is an EDG front-end. EDG can be configured to emulate GCC, Clang and CL, and emulate the differences between certain versions of GCC and Clang, but it continues to represent itself as EDG (via system defines) and does not provide a way to emulate different versions of EDG itself. It also disallows redefinition of the compiler defines that it uses internally. That is what you are seeing. The error is reported because the defines we are providing EDG take precedence over its own values. It's reporting the error as it tries to assign its own values and discovers that values are already present. So, your changes are being applied, which you can confirm by hovering over a For now, we could suppress the error from being reported if the define was part of a custom configuration. But that would not prevent other aspects of IntelliSense from failing due to internally inconsistent state in EDG. The ideal fix would be for us to determine the proper internal args to configure EDG with to most closely match the compiler, address features gaps needed to support that compiler, and provide an IntelliSense mode for it. (Does this issue properly track that for your compiler? ) |
Hi @Colengms, thanks for your reply, that explanation lines up with my observations of the error. At the moment we are working around the error by removing any EGD-related defines from configurations before sending them to cpptools. However, this means that IntelliSense will use its own values for these defines, not the compiler's values, so suppressing the error on your end would be a better fix. I agree that the ideal solution is specific support for IAR compilers (not just for the sake of this error, but also for e.g. keyword support as mentioned in the issue you linked). If this is something you want to go for, we at IAR would be available for e.g. answering questions about our compilers. Just tag me here on GitHub or send an email to Micael.Borgefeldt@iar.com (@micaelbo), and we'll work something out. |
@HampusAdolfsson We're tracking adding support for IAR compilers at #7653 (oops, I just noticed Colen already linked to that). The VS team worked with NVIDIA to add NVCC compiler support -- I'm looking into if there's someone you can contact about that... |
The macro redefinition errors are fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.2 |
Bug Summary:
I use a self-created microcontroller board based on a Renesas controller and the IAR development environment. With the IAR extension for VS Code, it is possible that Intellisense can properly connect all paths, defines, types, etc. and everything works nicely. As of extention version 1.9.7 of C/C++, a command line error is always displayed that a macro definition is invalid, although this is not the case! If you jump back to version 1.8.4 everything is ok.
Steps to reproduce:
Install the latest extension c/c++ and the latest IAR For Visual Studio Code from pluyckx.iar-vsc
Download the attached file bug_on_vs_code.zip
Unpack the files an open the VSC-WS file in the .vscode folder
browse in VS Code to the file: r_bsp_config_reference and then you get the command line error. this is just one example of this behavior from the C/C++ extension.
If you now downgrade the c/c++ version to 1.8.4 and restart vs code, the error disappear
VS Code Version:
![2022-06-13 10_13_47-Visual Studio Code](https://user-images.githubusercontent.com/107396328/173311636-e617f239-b6c6-4d3f-908c-c002216af8d2.png)
Example of macro definition error:
![image](https://user-images.githubusercontent.com/107396328/173311824-d483c5da-dc4b-47a6-8d4a-cd96b88c7c67.png)
The text was updated successfully, but these errors were encountered: