X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FPreprocessor.h;h=800608d4afc3562569c50e048299ceca03ff7b18;hb=9276f2a5646a94eda765c92b171b98c499313213;hp=49bbc7109466f7307ebe46f084af2842d6b6b900;hpb=321542683a01c3f334047531e9b487f047129775;p=folly.git diff --git a/folly/Preprocessor.h b/folly/Preprocessor.h index 49bbc710..800608d4 100644 --- a/folly/Preprocessor.h +++ b/folly/Preprocessor.h @@ -16,8 +16,7 @@ // @author: Andrei Alexandrescu -#ifndef FOLLY_PREPROCESSOR_ -#define FOLLY_PREPROCESSOR_ +#pragma once /** * Necessarily evil preprocessor-related amenities. @@ -47,6 +46,10 @@ #define FB_THIRD(a, b, ...) __VA_ARGS__ #endif +// MSVC's preprocessor is a pain, so we have to +// forcefully expand the VA args in some places. +#define FB_VA_GLUE(a, b) a b + /** * Helper macro that extracts the first argument out of a list of any * number of arguments. @@ -58,7 +61,14 @@ * number of arguments. If only one argument is given, it returns * that. */ +#ifdef _MSC_VER +// GCC refuses to expand this correctly if this macro itself was +// called with FB_VA_GLUE :( +#define FB_ARG_2_OR_1(...) \ + FB_VA_GLUE(FB_ARG_2_OR_1_IMPL, (__VA_ARGS__, __VA_ARGS__)) +#else #define FB_ARG_2_OR_1(...) FB_ARG_2_OR_1_IMPL(__VA_ARGS__, __VA_ARGS__) +#endif // Support macro for the above #define FB_ARG_2_OR_1_IMPL(a, b, ...) b @@ -73,6 +83,16 @@ */ #define FB_SINGLE_ARG(...) __VA_ARGS__ +/** + * Helper macro that just ignores its parameters. + */ +#define FOLLY_IGNORE(...) + +/** + * Helper macro that just ignores its parameters and inserts a semicolon. + */ +#define FOLLY_SEMICOLON(...) ; + /** * FB_ANONYMOUS_VARIABLE(str) introduces an identifier starting with * str and ending with a number that varies with the line. @@ -92,5 +112,3 @@ * another macro expansion. */ #define FB_STRINGIZE(x) #x - -#endif // FOLLY_PREPROCESSOR_