Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected in macro formal parameter list Error

Tags:

c++

c

visual-c++

I'm an intern student and my boss told me to do porting from Linux c to Visual C++.

When I built the coding, I found this error "unexpected in macro formal parameter list", here is the code

#define cache_info(format, msg...)  
    do { \
        ;\
    } while (0)  

I don't know what is wrong and what the coding is for .

I can't also ask the Linux programmer since he is out. Can someone help me ???

like image 796
kevin Avatar asked Mar 02 '11 02:03

kevin


2 Answers

Sounds like your version of Visual C++ doesn't support variadic macros.

you might need to try something like this to get it to work.

#define FUNC(foo)  ThisFunc foo

void ThisFunc(int, ...);

int main()
{
    FUNC((123, 456));
}

or you could just be missing a comma?....

#define cache_info(format, msg,...)  
like image 180
Pablitorun Avatar answered Nov 13 '22 13:11

Pablitorun


I think that the problem could be from one of two things.

First, your macro is defined as

cache_info(format, msg...)

But you probably meant to write

cache_info(format, msg, ...)

Though this could just be a typo in your original post.

More importantly, though, macros with variable numbers of arguments ("variadic macros") are not supported in C++; they exist only in C. If you're trying to compile this C code with a C++ compiler, the compiler should give you an error here because the code isn't legal C++.

like image 25
templatetypedef Avatar answered Nov 13 '22 15:11

templatetypedef