blitz icon indicating copy to clipboard operation
blitz copied to clipboard

Defined macro CT in blitz/tau.h causes trouble when compiling project that uses Qt5/QColor.h

Open Iceman9 opened this issue 4 years ago • 2 comments

https://github.com/blitzpp/blitz/blob/39f885951a9b8b11f931f917935a16066a945056/blitz/tau.h#L52

This defined macro causes an issue of compiling projects that include blitz and Qt5, specifically QColor.h as shown in the following link:

https://github.com/qt/qtbase/blob/40143c189b7c1bf3c2058b77d00ea5c4e3be8b28/src/gui/painting/qcolor.h#L266

The error output doesn't help much. as the compiler only complains that the there is a mismatch in the number of arguments provided to the macro. It took as a while to hunt through the army of headers.

The solution was simple. I #undef the macro before including the Qt headers. We just wanted to know where was the origin.

I don't think something should be done, but I just want to mark it if someone else gets into this situation in the future.

Best regards

Iceman9 avatar Mar 15 '21 22:03 Iceman9

I run into the exact same problem compiling existing code on a prerelease of Ubuntu 22.04. Defining a two-letter maco is prone to ambiguity and, thus, is dangerous, isn't it ? Isnt't there a way to change this CT maco name (for, say, BLITZ_CT for instance), or is it a public API ?

denisri avatar Dec 03 '21 10:12 denisri

Thanks @Iceman9 for reporting and @denisri following up. The origin of the problem seems to be outside of Blitz, it is the tau profiler that defines the CT macro: https://www.cs.uoregon.edu/research/tau/docs/newguide/bk03rn01re146.html

In Blitz code, this definition is within an "#else" block of an "#ifdef BZ_TAU_PROFILING".

I guess, the best solution is to include this #ifdef BZ_TAU_PROFILING wherever the CT macro is used, i.e.:

  • https://github.com/blitzpp/blitz/blob/master/blitz/memblock.cc#L91
  • https://github.com/blitzpp/blitz/blob/master/blitz/array/methods.cc#L290
  • https://github.com/blitzpp/blitz/blob/master/blitz/array-impl.h#L200

slayoo avatar Dec 03 '21 21:12 slayoo