Search code examples
c++csqlitegccqmake

C++ version of system header files cannot be found


with "... after adding sqlite.c in project" I should continue, because every thing was fine. Headers like cassert, cerrno, cstdio, let say, c* do exist and normally compiler do see them and compile.

After adding sqlite3.c into the project, now I imagine that .h version of those header files (assert.h, errno.h, etc.) are being added into compilaton first, which then prevents including c* header files in other files.

The compiler reports this: "cassert: No such file or directory", which is not the truth.

I am compiling with qmake/gcc.

How could I fix this?

Edit: It seems that the problem is related with precompiled header. After @Caduchon's comment, I have looked again compilation log, then I saw this for precompiled header:

gcc -x c++-header pre.hpp

...

gcc -x c-header pre.hpp

Precompiled header is added into compilation 2 times. The second one is as c-header. I imagine that when there was no .c file in project, precompiled header was being processed only 1 time as c++-header. But when there is also a .c file, it is being compiled also as c-header.


Solution

  • The problem was because of precompiled header. When a .c file is introduced into project, then precompiled header was being compiled also as c-header file. Commenting out C++ part of the header for C-compiler resolved the problem:

    #ifdef __cplusplus
    #endif