#107 variadic message macros

open
3
2007-07-18
2007-07-18
No

The message macros defined in error.h (PLAYER_ERROR, PLAYER_WARN, etc.) would be much nicer if they had variable numbers of arguments instead of using multiple macros with different numbers of arguments (PLAYER_ERROR1, PLAYER_ERROR2, etc.).

This can be done by like this:
#define PLAYER_ERROR(msg, ...) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n" , ## __VA_ARGS__)

I know this is supported for newer versions of gcc (http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html) but I don't know about other compilers.

Discussion

  • Paul Varnell

    Paul Varnell - 2007-07-18
    • priority: 5 --> 4
     
  • Paul Varnell

    Paul Varnell - 2007-07-18
    • priority: 4 --> 3
     
  • Toby Collett

    Toby Collett - 2008-06-14

    Logged In: YES
    user_id=974361
    Originator: NO

    Possibly player should just pick up loggin support from a library such as log4cxx instead of these macros.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks