PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 27, 2022

[FIXED] How can -Wgnu-zero-variadic-macro-arguments warning be turned off with Clang?

 April 27, 2022     clang, suppress-warnings, warnings     No comments   

Issue

Context

I read Clang's "Controlling Diagnostics via Pragmas" section about turning off particular warnings. It works well in general for all warnings except for -Wgnu-zero-variadic-macro-arguments.

The code is:

MyHeader.hpp

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"

#import "header generating -Wgnu-zero-variadic-macro-arguments warning"

#pragma clang diagnostic pop

Problem

Clang generates -Wgnu-zero-variadic-macro-arguments warnings while compiling translation units importing MyHeader.hpp.

Env

Clang Version: Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn) Target: x86_64-apple-darwin13.4.0 Thread model: posix

OS: Mac OS X 10.9.5


Solution

This seems to be working in Xcode 6.4 (6E35b). The pragma suppresses the warning now.

I have -Weverything in build settings. Without the diagnostic ignore I definitely get the warning:

Token pasting of ',' and __VA_ARGS__ is a GNU extension

Output from Terminal to match your Env section:

$ clang --version
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix

Using the following code:

#define DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#import "Macros.h"
#pragma clang diagnostic pop

In which Macros.h contains:

#ifdef DEBUG
#define AssLog(condition, message, ...) NSAssert(condition, message, ##__VA_ARGS__)
#else
#define AssLog(condition, message, ...) if (!condition) NSLog((@"%@ [Line %d] " message), [NSString stringWithUTF8String:__PRETTY_FUNCTION__], __LINE__, ##__VA_ARGS__)
#endif


Answered By - Jeff
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing