PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: Warnings with Macros
Date: Wednesday, 16 Sep 2020, 17:19:39


    > My name is Mawuli Akpalu, and I am in your CPSC 323 class. I decided to
    > use your fiend.h header file because find the macros helpful, but I keep
    > getting warnings from gcc  of the form:
    >
    > fiend.h:19:43: warning: too many arguments for format [-Wformat-extra-args]
    >    19 | #define WARN(format,...) fprintf (stderr, "fiend: " format "\n",
    > __VA_ARGS__)
    >       |                                           ^~~~~~~~~
    > fiend.h:22:26: note: in expansion of macro M-bM-^@M-^XWARN'
    >    22 | #define DIE(format,...)  WARN(format,__VA_ARGS__), exit
    > (EXIT_FAILURE)
    >       |                          ^~~~
    > fiend.c:181:9: note: in expansion of macro M-bM-^@M-^XDIE'
    >   181 |    else DIE("missing argument to -maxdepth", empty);

The error is in the last line, where there is one
argument (empty) but the format does not require any.

But trying to remove empty leads to a different error,
since the DIE() macro must have at least two arguments.

Try
  DIE("missing argument to -maxdepth%s", "");
instead.

--Stan-
PREV INDEX NEXT