|
[Rivet] "#define B0" in system include clashes with Rivet PDGIDAndy Buckley andy.buckley at cern.chWed May 2 17:13:47 BST 2018
Ah, I guess from the name that "termios.h" is a Mac thing? We don't explicitly request that header anywhere... I wonder what in your system libraries is pulling it in. Andy On 2 May 2018 at 13:44, Stefan Richter <stefan.richter at cern.ch> wrote: > Hi Andy, > the macro is defined in /usr/include/sys/termios.h. You can spot this in > the compiler error message at the end of my original message. I've checked > the file, it defines many B?, where ? is an integer. > > My current solution: I add #undef B0 to the beginning of > Rivet-2.5.4/include/Rivet/Tools/ParticleName.hh. I'm happy to hear more > robust/elegant solutions, but if this runs, I can live with it. > > 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... > > Yes, the fact that the scope of preprocessor actions cannot be (robustly) > restricted on the user code side is what I was lamenting. In other words, > the fact that the compartmentalisation provided by namespaces can be broken. > > Best regards, > Stefan > > > On 2 May 2018, at 14:37, Andy Buckley <a.g.buckley at gmail.com> wrote: > > 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 > > > -- 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/41196a57/attachment.html>
More information about the Rivet mailing list |