Skip to content

develop branch - support for printf with no parameters #31

Description

@GiovanniCmpaner

I'm trying to use printf with empty parameters, like:

printf("Just a debug string")

Currently, I get a compiler error with the original code.

The solution is to change these lines:

#define sprintf(buff, str, ...) GString(buff).printf(str, __VA_ARGS__)
#define xprintf(out, str, ...) PrintEx(out).PRINTF_ALIAS(str, __VA_ARGS__)

#define printf(format, ...) PRINTF_ALIAS(format, __VA_ARGS__)

To:

#define sprintf(buff, str, ...) GString(buff).printf(str, ##__VA_ARGS__)
#define xprintf(out, str, ...) PrintEx(out).PRINTF_ALIAS(str, ##__VA_ARGS__)
#define printf(format, ...) PRINTF_ALIAS(format, ##__VA_ARGS__)

Note the leading ## in __VA_ARGS__

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions