Skip to content

Instantly share code, notes, and snippets.

@nil-ableton
Last active June 7, 2016 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nil-ableton/6bb031802e2c2447af0f81bce86a6dea to your computer and use it in GitHub Desktop.
Save nil-ableton/6bb031802e2c2447af0f81bce86a6dea to your computer and use it in GitHub Desktop.
spaces in macro and boost::icl
/*
Encountered while building with FASTbuild cache on a library using boost::icl
See element_iterator.hpp and ICL_INTERVAL_TYPE.
FASTbuild uses cl.exe -P to produce a pre-processed file. That file gets a const stitched onto it.
Steps to reproduce:
1- compile with cl.exe clmacro.cpp
2- compile with cl.exe -P -Ficlmacro.i.cpp clmacro.cpp && cl.exe clmacro.i.cpp
Expected:
- 1 & 2 compile
Observed:
- only 1 compiles
*/
#define funny_type(__x) __x
// this fixes it in MSVC:
#define funny_type_guard
#define funny_type2(__x) __x funny_type_guard
int main(void)
{
funny_type(int)const a = 2; // cl.exe -P clmacro.cpp -> `intconst a`
funny_type2(int)const b = 4; // cl.exe -P clmacro.cpp -> `int const b`
}
@gck-ableton
Copy link

Does this happen with cl.exe -E, too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment