How to fix unexpected in macro formal parameter list error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kevinkwh
    New Member
    • Feb 2010
    • 13

    How to fix unexpected in macro formal parameter list error?

    Hi,
    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 coding " #define cache_info(form at, msg...) \
    do { \
    ;\
    } while (0) " . I don't know what is wrong and what the coding is for . I can't also ask the Linus programmer since he is out. Can someone help me ???
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Is it really true that the macro expansion does not refer to the parameters? How odd.

    The "..." in the parameter list of the macro definition is suspicious. Search through your code for instances where this macro is called -- how many parameters are passed each time?

    Comment

    • kevinkwh
      New Member
      • Feb 2010
      • 13

      #3
      I can't find anything which uses cache_info. Some suggested me to put comma before ... , so it no longer shows error but I'm not really sure whether it is right or wrong !!! In fact, I don't understanding anything about those. Thanks !!!

      Comment

      • donbock
        Recognized Expert Top Contributor
        • Mar 2008
        • 2427

        #4
        You could find out if the macro is being used by suppressing its definition. Bracket the macro definition by "#if 0" and "#endif" and then rebuild your program. You should get an error for each time the macro is called.

        "..." in the macro definition suggests the author intended for the macro to accept a variable number of parameters. That was a nonstandard compiler feature until the C99 standard was approved. If the program was originally written for a compiler that wasn't C99-compliant, then it had some idiosyncratic syntax for variable macro parameter lists. There would be no reason to expect this syntax to match that of your new compiler. For that matter, many pre-C99 compilers didn't support this feature at all.

        Is it really true that the definition of this macro has no instructions within the do-while block?

        Comment

        Working...