[PATCH] D33080: [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows

Ben Craig via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 11 06:36:56 PDT 2017


bcraig added a comment.

I like the warning that you generate for min and max macros existing.  Is the push_macro / pop_macro the right way to go though?  You could throw extra parenthesis around the declaration and usages of min/max to avoid macro expansion.

  #define add(x,y) (x)-(y)
  
  template <typename T>
  T (add)(T x, T y) // parens around add to suppress macro
  {
      return x+y;
  }
  
  int main() {
      return 
          (add)(5, 4) + // uses function
          add(5, 4);    // uses macro
  }


https://reviews.llvm.org/D33080





More information about the cfe-commits mailing list