Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Invoking macro with less arguments than parameters

eldienerMar 27 2015 — edited Mar 30 2015

Section 16.3 paragraph 4 of the C++11 standard reads:

"If the identifier-list in the macro definition does not end with an ellipsis, the number of arguments (including those arguments consisting of no preprocessing tokens) in an invocation of a function-like macro shall equal the number of parameters in the macro definition. Otherwise, there shall be more arguments in the invocation than there are parameters in the macro definition (excluding the ...). There shall exist a ) preprocessing token that terminates the invocation."

When compiling Solaris Studio C++ 12.4 with the '-std=c++11' compiler flag:

#define AMACRO(x,y,z) x+y+z

int x = AMACRO(1);

should be to a preprocessing error.

Yet when invoked with the the compiler it instead only leads to a warning:

"Warning: Too few arguments in macro AMACRO"

Is there some compiler switch which will generate an error instead of a warning for this situation ?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 27 2015
Added on Mar 27 2015
6 comments
806 views