Open JAicewizard opened 2 years ago
Hi @JAicewizard . By default, when a .h
file is opened and there is no source file (.cpp
, .c
, etc.) to associate it with, the C/C++ extension treats the file as containing C++ code. I don't believe the restrict
keyword is supported in C++. Note this comment in the C++ specification.
I believe you could work around the issue if you add a .c
file that includes that header. That .c
file should be found when opening the header, and the header would be interpreted as containing C code instead of C++ code.
Does that resolve your issue?
That does "fix" the issue, but I have explicitly set the language to C, not C++.
So it is probably the case that the the language server misinterprets the file even though I told VScode explicitly that this is a C file.
Hi @JAicewizard . Thanks. We'll use this issue to track addressing that. In the meanwhile, it would also be possible to work around the issue by setting a file association in settings, like so:
{
"files.associations": {
"test.h": "c"
}
}
Yup this seems to work, even though vscode is now telling me it is in C++ mode, the c/c++ extension seems to be in C mode now. Maybe there is something not working with the language mode in vscode? Or maybe it doesnt do what I expect it to do.
Yeah, it seems like we may not be responding correctly to C versus C++ language mode changes from the status bar. I filed an issue at https://github.com/microsoft/vscode-cpptools/issues/9141 .
Bug type: Language Service
Describe the bug
void z(char *restrict q);
which is valid C code. Language is set to C.Steps to reproduce
Expected behavior No squiggly lines
Code sample and logs
Code sample
Configurations in
c_cpp_properties.json
Logs from running
C/C++: Log Diagnostics
from the VS Code command palette------- Workspace parsing diagnostics ------- Number of files discovered (not excluded): 26971 Number of files parsed: 3712