blitzpp / blitz

Blitz++ Multi-Dimensional Array Library for C++
https://github.com/blitzpp/blitz/wiki
Other
405 stars 84 forks source link

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

Open Iceman9 opened 3 years ago

Iceman9 commented 3 years ago

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

denisri commented 2 years ago

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 ?

slayoo commented 2 years ago

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.: