473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

macro passed wrong number of arguments

I'm using a matrix and vector library, that won't compile. When
running g++ I get the error message "macro "minor" passed 5 arguments,
but takes just 1"

The definition of "minor" looks like below, and it takes 3 arguments.
All calls to minor that I have found in the code also pass it three
arguments, so I really don't understand this error.

Does anything look suspicious with the following definition, or must
it be that there is some other definition of minor with a different
number of arguments somewhere?

template <int N, typename T>
T minor(const Vector<N,Vector<N,T> >& in, int row, int col) //ERROR
{
Vector<N-1,Vector<N-1,T> > tmp;
int dst_row, dst_col;
dst_row = 0;
for (int src_row = 0; src_row < N; src_row++) {
if (src_row == row) continue;
dst_col = 0;
for (int src_col = 0; src_col < N; src_col++) {
if (src_col == col) continue;
tmp[dst_row][dst_col] = in[src_row][src_col];
dst_col++;
}
dst_row++;
}
return det(tmp);
}

Thanks
/ martin
Jul 22 '05 #1
4 6179

"Martin Magnusson" <lo*******@frustratedhousewives.zzn.com> wrote in message
news:35**************************@posting.google.c om...
I'm using a matrix and vector library, that won't compile. When
running g++ I get the error message "macro "minor" passed 5 arguments,
but takes just 1"

The definition of "minor" looks like below, and it takes 3 arguments.
All calls to minor that I have found in the code also pass it three
arguments, so I really don't understand this error.

Does anything look suspicious with the following definition, or must
it be that there is some other definition of minor with a different
number of arguments somewhere?

template <int N, typename T>
T minor(const Vector<N,Vector<N,T> >& in, int row, int col) //ERROR
{


Yes, somewhere is defined a macro called minor (which takes one argument).
Look at the number of commas on the above line (four of them), therefore the
compiler thinks this is a macro invokation with five arguments.

This is a good example of why macros are evil, *especially* when they are
given common names like minor.

Find out who wrote that macro and shoot them (or at least sack them).

john
Jul 22 '05 #2
John Harrison wrote:
This is a good example of why macros are evil, *especially* when they
are given common names like minor.


And if you really have to write macros, write them (and _nothing_ else)
in all uppercase letters. It reduces the likelyness for name clashes
and it immediately shows that it's a macro.

Jul 22 '05 #3
"John Harrison" <jo*************@hotmail.com> wrote:
Find out who wrote that macro and shoot them (or at least sack them).


I'm using Cygwin, and the file /usr/include/sys/sysmacros.h has the
following definitions:

#ifdef __CYGWIN_USE_BIG_TYPES__
#define major(dev) ((int)(((dev) >> 16) & 0xffff))
#define minor(dev) ((int)((dev) & 0xffff))
#define makedev(major, minor) (((major) << 16) | ((minor) & 0xffff))
#else
#define major(dev) ((int)(((dev) >> 8) & 0xff))
#define minor(dev) ((int)((dev) & 0xff))
#define makedev(major, minor) (((major) << 8) | ((minor) & 0xff))
#endif

So this was the culprit. Weird that the Cygwin developers would define
such macros. (I wonder what they are for).
Jul 22 '05 #4
Martin Magnusson wrote:
"John Harrison" <jo*************@hotmail.com> wrote:
Find out who wrote that macro and shoot them (or at least sack them).

I'm using Cygwin, and the file /usr/include/sys/sysmacros.h has the
following definitions:

#ifdef __CYGWIN_USE_BIG_TYPES__
#define major(dev) ((int)(((dev) >> 16) & 0xffff))
#define minor(dev) ((int)((dev) & 0xffff))
#define makedev(major, minor) (((major) << 16) | ((minor) & 0xffff))
#else
#define major(dev) ((int)(((dev) >> 8) & 0xff))
#define minor(dev) ((int)((dev) & 0xff))
#define makedev(major, minor) (((major) << 8) | ((minor) & 0xff))
#endif

So this was the culprit. Weird that the Cygwin developers would define
such macros. (I wonder what they are for).


They're used for device drivers. In *nix, a device is identified by a
major number and a minor number. In practice, the device number is a
single int. So major and minor are macros that split the dev number out
into its components.

The cygwin guys should have either all capped them (they didn't for
historical reasons), or provided some #ifdef so you could turn them off.
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Andrew Dalke | last post by:
Here's a proposed Q&A for the FAQ based on a couple recent threads. Appropriate comments appreciated X.Y: Why doesn't Python have macros like in Lisp or Scheme? Before answering that, a...
1
by: Martin Magnusson | last post by:
I'm using a matrix and vector library, that won't compile. When running g++ I get the error message "macro "minor" passed 5 arguments, but takes just 1" The definition of "minor" looks like...
7
by: A. Saksena | last post by:
Hi all, Is it possible to write a function or a macro in C++, which is capable of accepting any number of arguments. To give an example, the following should be possible: - ...
7
by: Peter Ammon | last post by:
K.N. King's book "C Programming: A Modern Approach" gives this exercise in chapter 14, which is about the preprocessor: The following macro has a subtle problem: #define ABS(a)...
20
by: Srinivas Mudireddy | last post by:
Hi, I am facing a problem with trying to conditionally compile inside a macro. I have a macro #define SET_VAL(x, y) ((x) = *(y)) But the problem is y can be NULL in which case I want to set...
10
by: Praveen.Kumar.SP | last post by:
Hi Could anyone solve the problem for the code below The Code: #include "stdio.h" #include "iostream.h" void Temp( int a, char* str,...)
12
by: Laurent Deniau | last post by:
I was playing a bit with the preprocessor of gcc (4.1.1). The following macros expand to: #define A(...) __VA_ARGS__ #define B(x,...) __VA_ARGS__ A() -nothing, *no warning* A(x) -x ...
5
by: martin.brodeur | last post by:
I unable to pass a template type with two parameters to a very simple macro with g++ 3.4 (Linux x86): for example: #define THIS_IS_A_MACRO(token) BOOST_PP_STRINGIZE(token) void foo() {...
5
by: Francois Grieu | last post by:
One of the C compiler that I use <OT>(Keil's CX51)</OTbarks at #define a(b) b int main(void){return a( #if 0 #endif 0);} More generally, this compiler seems confused by any preprocessing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.