Fake error with structure
-
Hi,
Qt Creator highlights these constructs as an error in a C project:
But it compiles without errors. When you hover your mouse over this line, a message appears:
unexpected token 'struct'
You can reproduce by creating an empty Non-Qt C project: File > New Project > Non-Qt Project > Plain C Application
main.c
#include <stdio.h> struct myStructure { int a; int b; }; int main() { struct myStructure s = (struct myStructure){1, 2}; return 0; }
Maybe is the bug report already exist? Or should I create a new bug report?
-
@8Observer8 said in Fake error with structure:
Or should I create a new bug report?
What code model do you use? If it is not clang but the internal I don't think it's worth reporting a bug.
-
@Christian-Ehrlicher said in Fake error with structure:
What code model do you use? If it is not clang but the internal
I don't understand what do you mean. I've download Qt Creator 15.0.0 here: https://github.com/qt-creator/qt-creator/releases I have CMake 3.27 and MinGW 14.2: https://github.com/skeeto/w64devkit/releases. I just want to use pure C language with CMake. I've created a project like this:
-
@8Observer8 ,
The same behavior also occurs on macOS in Qt 6.7.3. -
@8Observer8 , @Bondrusiek
Creator, your project and compiler are not really the issue. You say the code compiles fine, what you see is internal to Creator editor IDE where it (tries to do) code completion for you. And it is apparently getting it wrong, happens. Go find what Code Completion you are using in Creator's settings. If that is clang it might be worth reporting an error, but if it is the old, internal one in Creator don't bother, try changing it to clang if you can. -
I use this configurations:
and
is it fine ?
-
@Bondrusiek , @8Observer8
Ubuntu 24.04, Qt 6.4.2, Creator 13.0 from distro. I create a new Plain C project, I paste in @8Observer8'sstruct
code above. I do not get any complaint/warning in the IDE.I have the same settings as your Installed Plugins.
I think the relevant setting is Edit > Preferences > C++ > Clangd
-
Same thing with me too. If I checked the use clangd checkbox and the warning disappeared in the IDE. Thx for this info.
-
@Bondrusiek
If you do not Use clangd then it uses an old, internal one which is not maintained/changed much any longer.