I'm writing a class that has a matrix-like structure and I want to have a member function named minor to be the same as the matrix operation. This triggers some errors. A minimal test case on my system:
#include <iterator>
void minor(int row, int col);
When compiled, clang provides the following error:
$ clang++ -Weverything -std=c++11 test.cpp
test.cpp:2:21: error: too many arguments provided to function-like macro invocation
void minor(int row, int col);
^
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:67:10: note: macro 'minor' defined here
# define minor(dev) gnu_dev_minor (dev)
^
test.cpp:2:6: error: variable has incomplete type 'void'
void minor(int row, int col);
^
2 errors generated.
$
The relevant portion of sys/sysmacros.h is:
/* Access the functions with their traditional names. */
# define major(dev) gnu_dev_major (dev)
# define minor(dev) gnu_dev_minor (dev)
# define makedev(maj, min) gnu_dev_makedev (maj, min)
Clearly, these specific macros could be #undef'd, but it seems quite silly that such routine words as major and minor would be defined as macros, particularly when pulling in part of the C++ standard library. Is there some reason these need to be defined? Is this a bug in the standard library I'm using? (libstdc++ 4.8.2 as in Debian testing)
-std=c++11 -ansi
– Sunup