Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[cxxmodules] #undef I coming from complex.h
If we preload the core modules that can contain complex.h, we
break a lot of tests that name variables or template arguments I.
  • Loading branch information
Teemperor committed Nov 14, 2017
commit 6d42945ca5579f952fbf6af80cac6d57ae6afcad
9 changes: 9 additions & 0 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,15 @@ static void LoadCoreModules(cling::Interpreter &interp)
for (StringRef H : moduleHeaders) {
declarations << "#include \"" << H.str() << "\"\n";
}

// C99 decided that it's a very good idea to name a macro `I` (the letter I).
// This seems to screw up nearly all the template code out there as `I` is
// common template parameter name and iterator variable name.
// Let's follow the GCC recommendation and undefine `I` in case any of the
// core modules have defined it:
// https://www.gnu.org/software/libc/manual/html_node/Complex-Numbers.html
declarations << "#ifdef I\n #undef I\n #endif\n";

auto result = interp.declare(declarations.str());

if (result != cling::Interpreter::CompilationResult::kSuccess) {
Expand Down