2

I am currently in the process of moving a number of class files from our Visual Studio source environment into Qt Creator (version 3.4.2).

I have made several changes to cater for the differences in the compiler (into MinGW). One thing that is puzzling me is that the the IDE is reporting a specific error (red underline) but still compiles fine.

I am pretty sure the issue is isolated to using reinterpret_cast<T> where T is a global namespace.

For example, the following line will show as incorrect in the IDE but will still compile:

::GetWindowThreadProcessId(window, reinterpret_cast<::LPDWORD>(&processId));

The tooltip states:

expected ';' got ':'

If I change the code to remove :: from LPDWORD the syntax highlighting disappears. This will be fine in the IDE:

::GetWindowThreadProcessId(window, reinterpret_cast<LPDWORD>(&processId));

I suspect this is a bug in the IDE. Is this a safe assumption?

I don't plan on changing the code style for using the global namespace.

Class Skeleton
  • 2,913
  • 6
  • 31
  • 51
  • 5
    I don't know for sure, but probably the error is caused by the digraph `<:`. Make a space between `<` and `::` and check if it helps. Also, without this space the code will fail to compile. More on digraps here https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C – lisyarus Jul 31 '15 at 13:00
  • @lisyarus Adding the space seemed to help with the IDE complaint and it compiles – Class Skeleton Jul 31 '15 at 14:05
  • 2
    Qt Creator uses its own C++ parser by default. This parser isn't a full, standards-compliant C++ parser by necessity. You can try out the experimental LLVM-based code model instead, it should accept anything that LLVM will. – Kuba hasn't forgotten Monica Jul 31 '15 at 16:24

1 Answers1

0

Thanks to lisyarus's comment, I was able to find that this is in fact a bug in QT Creator. There is already a bug report here.

As I mentioned in the question, the bug doesn't stop you from compiling the code. You can, if you wish, add a space between < and ::.

Class Skeleton
  • 2,913
  • 6
  • 31
  • 51