[Rivet] "#define B0" in system include clashes with Rivet PDGID

Andy Buckley andy.buckley at cern.ch
Wed May 2 13:37:17 BST 2018


Hi Stefan,

Do you know what header defines this B0 macro? It's not a problem I've ever
seen. Compiler-level macros should have names prefixed by
double-underscores to avoid this problem, I think, so it must be coming
from a "user space" header... but which one?

This isn't just a modularisation thing -- we already namespace these PID
codes. It's more generally about inability to restrict the scope of #define
and other dumb preprocessor mechanisms...

Andy


On 2 May 2018 at 12:54, Stefan Richter <stefan.richter at cern.ch> wrote:

> Dear Rivet developers,
> I'm experiencing a very annoying compile-time clash because the variable
> B0 is #defined (to 0) in a header that gets #included in Rivet… where it
> clashes with Rivet's PDGID definition of the neutral B meson. See the
> compiler printouts below.
>
> Do you have an elegant solution for this? Or should I add an #undef line
> to the Rivet source?
>
> Thank you!
> Stefan
>
> PS: I wish C++ had a module system like Python to prevent this from
> happening.
>
> clang++ -std=c++11 -Wno-unused-result -Wsign-compare -Wunreachable-code
> -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
> -pipe -Os -I/Users/stefanrichter/Software/local/src/Rivet-2.5.4/include
> -I/Users/stefanrichter/Software/local/src/Rivet-2.5.4/include
> -I/opt/local/Library/Frameworks/Python.framework/
> Versions/3.6/include/python3.6m -c rivet/core.cpp -o
> build/temp.macosx-10.13-x86_64-3.6/rivet/core.o -I/Users/stefanrichter/Software/local/include
> -O2 -Wno-sign-compare -I/Users/stefanrichter/Software/local/include
> -I/Users/stefanrichter/Software/local/include -I/Users/stefanrichter/Software/local/include
> -I/opt/local/include
> In file included from rivet/core.cpp:456:
> In file included from /Users/stefanrichter/Software/
> local/src/Rivet-2.5.4/include/Rivet/AnalysisHandler.hh:5:
> In file included from /Users/stefanrichter/Software/
> local/src/Rivet-2.5.4/include/Rivet/Config/RivetCommon.hh:20:
> /Users/stefanrichter/Software/local/src/Rivet-2.5.4/include/
> Rivet/Tools/ParticleName.hh:122:24: error: expected unqualified-id
>     static const PdgId B0 = 511;
>                        ^
> /usr/include/sys/termios.h:291:12: note: expanded from macro 'B0'
> #define B0      0
>                 ^
> 1 error generated.
> error: command 'clang++' failed with exit status 1
>
>
> _______________________________________________
> Rivet mailing list
> Rivet at projects.hepforge.org
> https://www.hepforge.org/lists/listinfo/rivet
>



-- 
Dr Andy Buckley, Lecturer / Royal Society University Research Fellow
Particle Physics Expt Group, University of Glasgow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.hepforge.org/lists-archive/rivet/attachments/20180502/12aacf83/attachment.html>


More information about the Rivet mailing list