Page MenuHome

Fix: _CONCAT warning from MSVC
AbandonedPublic

Authored by Ray Molenkamp (LazyDodo) on Oct 27 2022, 5:41 PM.

Details

Summary

msvc currently warns about

[2879/4971] Building CXX object source\blender\draw\CMakeFiles\bf_draw.dir\intern\draw_manager_data.cc.obj
K:\BlenderGit\blender\source\blender\draw\intern\../../blenlib/intern/list_sort_impl.h(58): warning C4005: '_CONCAT': macro redefinition
k:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\xatomic.h(23): note: see previous definition of '_CONCAT'

This header hasn't changed much since it got introduced in rB867cd2048e0e: Replace linked-list insert-sort with merge-sort but i suppose it got included from some C++ code that dragged in a system header it did not drag in before.

Who's in the wrong? Clearly us, the c++ spec says globals starting with _ (lib.global.names section from the C++ spec) are reserved to the implementation, us picking something common as _CONCAT only made a collision more likely to happen.

Now I can see wanting to limit the visibility in the rest of the codebase, so i understand why we chose to make it start with an underscore, but it can't stay like this. I changed all prefixes to _BLI_xxxx , we'd still violate spec, but it be a lot less likely to collide

I would also accept spec compliant BLI_xxxx but that may risk people actually using this. which is fine, but this macro should likely not live in this header if that's the case.

Diff Detail

Repository
rB Blender
Branch
tmp_concat_fix (branched from master)
Build Status
Buildable 24420
Build 24420: arc lint + arc unit