0

we recently ran into a problem that QtCreator fails to interpret hpp header files. Error messages like "Expected a function declaration" on namespace A { or "Expected ';' got 'class' on class B { are shown and the syntax highlighting doesn't work correcltly.

We found out that this issue is related to the following compiler flags:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

By deleting the first line (CMAKE_C_FLAGS std=gnu99), QtCreator interprets the herader files correctly.

Somehow QtCreator seems to use CMAKE_C_FLAGS for parsing c++ header files.

Is this maybe a issue with QtCreator? Do we miss something?

T. N.
  • 66
  • 7

1 Answers1

0

test this line of code

set(CMAKE_CXX_STANDARD 11)

and also use this link

Ehsan Panahi
  • 130
  • 5
  • Could you explain why and how this answers the question? – anothernode Jul 23 '18 at 08:19
  • This does not solve the problem, by adding this line we still can't set CMAKE_C_FLAGS to -std=gnu99 without destroying syntax highlighting in QtCreator – T. N. Jul 24 '18 at 08:48