We don't compile the widgets portion of Qwt, so that particular example doesn't affect us (I imagine the compiler will error out on a name clash even with identical values).
However, you can group the source files (cotire makes it easy to do), e.g. compile the widgets in a separate unity file group, and just make sure you have no conflicts inside these groups.
For name clashes the compiler will always warn or display errors about them. If the code changes are impossible, the problematic cases can also be worked around by manually disabling unity builds for individual files or by splitting them into different unity groups.
For sources that are ours, we tend to do those declarations as static const member variables of classes (sometimes of private implementation classes), or simply prefix them in a way that ensures uniqueness (e.g. qwt_arrowbtn_margin and qwt_legend_label_margin). Hiding all that stuff in private implementation class is usually the way to go.
While it may look like a lot of work, it's actually a lot easier than it looks, just follow some simple rules, and the compiler always says if something is wrong. I was able to create a full unity build of a project (~1400 files, ~250K loc) in just a couple of hours, including setting it all up.
Cheers,
Alexander
Bookmarks