osyan
osyan

Reputation: 1856

macro passed 2 arguments, but takes just 1

my code didn't build successfully with this error message:

macro "hton_us" passed 2 arguments, but takes just 1

and it occurs on this line:

hton_us( &fi.size, 1 );

here is the refrence to hton_us

void hton_us( iu16 *us, iu8 num )
{
    iu16 local;

    while( num-- ) {
        local=*us;
        *us++=swap_us(local);
    }
}

I read in some similar question that told to use typedef but it didn't help me.

Upvotes: 1

Views: 12403

Answers (2)

Richard J. Ross III
Richard J. Ross III

Reputation: 55563

Using a little C preprocessor trick, you can skip the macro and just call the function:

(hton_us)(&fi.size, 1);

By surrounding hton_us in parentheses, it tells the compiler that this macro cannot be expanded, because it wasn't called with any args, and thus the function gets called instead.

Upvotes: 4

marcinj
marcinj

Reputation: 49986

Check your header files, you probably have following there:

#ifndef ENDIAN_LITTLE
#define hton_us(us)
#define hton_ul(ul)
#endif

so probably ENDIAN_LITTLE is not defined

Upvotes: 3

Related Questions