Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt creator could not parse stddef.h --> incorrect code completion and highlighting

I am developing a QT GUI for my application using QT Creator (4.11.0).

Recently, our IT updated my OS to Ubuntu 20.04 (from 18.04) - maybe the error is related to that.

I have not touched to project in some month but yesterday wanted to continue developing it. However, within the IDE there are now thousands of errors highlighted at almost every line of my code. (with highlighted I mean that there is this red background and a red dot beside the line number)

On the very top, it says:

Warning: The code model could not parse an included file, which might lead to incorrect code completion and highlighting, for example.
cstddef:50:10: fatal error: 'stddef.h' file not found
...

The errors that are listed in the IDE are very wired like:

type `QMainWindow`is not a direct or virtual base of `MainWindow` (my class is called `MainWindow`)

I'm pretty sure it is not related to my code:

  • the code compiles and works fine - it is really just the IDE that is highlighting errors at every line of my code.
  • I have the same code on a Windows Computer and there no errors are listed in the IDE.
  • even if I start a brand new QT Widget project the errors appear within the template code provided by the QT Creator.

Since the GCC version changed with the update of the OS, I thought maybe I have to define a new KIT but this also did not help.

Is there anything I can do to fix the issue? Do I have to reinstall the QT Creator?

I know, pictures are not very well-liked but here I think it might help to understand what I mean with "IDE is highlighting errors": enter image description here

like image 455
user7431005 Avatar asked Feb 02 '26 02:02

user7431005


1 Answers

1. First

~/.profile :

CPATH="/usr/include/clang/10/include:$CPATH"
C_INCLUDE_PATH="/usr/include/clang/10/include:$C_INCLUDE_PATH"
CPLUS_INCLUDE_PATH="/usr/include/clang/10/include:$CPLUS_INCLUDE_PATH"

export CPATH
export C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH

maybe /usr/include/clang/10/include see in you file system.

2. Second

Logout / login.

3. Third

Specifying Build Settings (Projects -> Build -> in every config build) in Build Environment section: [unset] CPATH, C_INCLUDE_PATH and CPLUS_INCLUDE_PATH or [edit] replace this variable with the necessary values

like image 138
user3744156 Avatar answered Feb 03 '26 15:02

user3744156