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

Resolving 'Unknown Compiler' Error in clangd Plugin: Troubleshooting and Solutions #624

Open
DYAAL opened this issue Apr 21, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@DYAAL
Copy link

DYAAL commented Apr 21, 2024

The clangd plugin is reporting an error: "In included file: Unknown compiler." However, my compilation and other functionalities work fine. How can I get rid of this error?

image

@DYAAL DYAAL added the bug Something isn't working label Apr 21, 2024
@HighCommander4
Copy link
Contributor

Please share clangd logs

@DYAAL
Copy link
Author

DYAAL commented Apr 22, 2024

请分享clangd 日志

image
The clangd log is shown as above.

This question might be related to the fact that I'm using cross-compilation. Here's my clangd configuration:
image

@HighCommander4
Copy link
Contributor

The clangd log is shown as above.

That's not a log, that's a screenshot of something (the hover shown on the diagnostic I guess).

Please take another look at the instructions I linked to for getting logs. They are found in the "Output" view. Please share the full log in text form.

Here's my clangd configuration:

I think when you provide multiple --query-driver arguments, a later one overrides the earlier one.

If you want to specify multiple patterns, you can do that by separating them with a comma, e.g.

--query-driver=/path/one,/path/two

@DYAAL
Copy link
Author

DYAAL commented Apr 24, 2024

The clangd log is shown as above.

That's not a log, that's a screenshot of something (the hover shown on the diagnostic I guess).

Please take another look at the instructions I linked to for getting logs. They are found in the "Output" view. Please share the full log in text form.

Here's my clangd configuration:

I think when you provide multiple --query-driver arguments, a later one overrides the earlier one.

If you want to specify multiple patterns, you can do that by separating them with a comma, e.g.

--query-driver=/path/one,/path/two

here is my clangd logs, I hope this may help you to find the problem.
clangd_log.txt

Thanks a lot for your help!

@HighCommander4
Copy link
Contributor

HighCommander4 commented Apr 24, 2024

The logs show that the "unknown compiler" error is coming from an #error directive in the file d:/001_my_Rapier/my_Rapier/Drivers/CMSIS/Include/cmsis_compiler.h. Could you share the contents of this file?

@DYAAL
Copy link
Author

DYAAL commented Apr 25, 2024

cmsis_compiler.h

Certainly. Additionally, the clangd plugin will report an error "Call to undeclared function 'XXXXX'; ISO C99 and later do not support implicit function declarations", but my code compiles without issues. This is also somewhat perplexing.
image
GitHub doesn't allow directly uploading .h files, so I renamed it as a .txt file before uploading.

cmsis_compiler.txt

@HighCommander4
Copy link
Contributor

cmsis_compiler.txt

It looks like this file expects that you're using one of a specific set of compilers, and clang doesn't seem to be one of them. So, it's possible that this project does not support clang as a compiler, which might mean not supporting clang-based tools like clangd either.

That said, I notice that one of the preprocessor branches checks for __GNUC__ (which is defined by the GCC compiler), and I believe clang does define this macro in an attempt to be compatible with GCC.

What compiler are you actually building your code with? Are you able to build it with clang?

@DYAAL
Copy link
Author

DYAAL commented Apr 26, 2024

It looks like this file expects that you're using one of a specific set of compilers, and clang doesn't seem to be one of them. So, it's possible that this project does not support clang as a compiler, which might mean not supporting clang-based tools like clangd either.

That said, I notice that one of the preprocessor branches checks for __GNUC__ (which is defined by the GCC compiler), and I believe clang does define this macro in an attempt to be compatible with GCC.

What compiler are you actually building your code with? Are you able to build it with clang?

This project is an ARM project and is compiled through cross-compilation. However, the compiler used is probably the one included with Keil, named armcc.exe, and this might have caused some issues. By the way, can clang support cross-compilation? I haven't tried this feature before, but it's always a hassle to build files like Makefile or Cmake from scratch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants