2

Does enclosing the definition in parenthesis make any difference?

I'm asking because the Qt moc compiler crashes when it sees the latter variant enclosed in parenthesis and WINDOWS is defined.

Update: Upgraded from Qt 5.4.2 to Qt 5.6 and I no longer see the problem.

Petter Kvalvaag
  • 323
  • 2
  • 11
  • 3
    That sounds like a serious bug in `moc`. A crash is always a bug, of course, but they are equivalent and the latter isn't even uncommon. – molbdnilo Jul 05 '16 at 11:49
  • Yes, I've only seen this when the definition is far down the include hierarchy, so there may be other unfortunate circumstances causing this. All I know is that removing the parenthesis fixes it, but it would be nice to isolate the root cause and get it reported. – Petter Kvalvaag Jul 05 '16 at 11:58

1 Answers1

4

No, there is no semantic difference in this case. But moc's understanding of both C++ and preprocessing directives is somewhat limited, so it can often be necessary to tweak some constructs to please its simple mind.

In this case you could also use #ifdef WINDOWS for identical results.

Jesper Juhl
  • 30,449
  • 3
  • 47
  • 70