Commit 2b4d8424 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Adam Wujek

assert.h: parameter passing fix

See gcc info pages: "Macros with a Variable Number of Arguments."
The ISO-C stadanrd doesn't allow varargs macros to get zero or more
arguments. So this fixes the problem using the gcc extension.

A standard-compliant alternative would be to have "fmt" included in
the variadic part, like this:

  #define assert(cond, ...) \
        if (CONFIG_HAS_ASSERT && !(cond)) \
                __assert(__func__, __LINE__, 1 /* forever */, __VA_ARGS__)

But the reader wouldn't  now it's a fmt+args.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <>
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <>
parent 8bd086ca
......@@ -13,11 +13,11 @@ extern void panic(const char *fmt, ...)
#define assert(cond, fmt, ...) \
if (CONFIG_HAS_ASSERT && !(cond)) \
__assert(__func__, __LINE__, 1 /* forever */, fmt __VA_ARGS__)
__assert(__func__, __LINE__, 1 /* forever */, fmt, ## __VA_ARGS__)
#define assert_warn(cond, fmt, ...) \
if (CONFIG_HAS_ASSERT && !(cond)) \
__assert(__func__, __LINE__, 0 /* once */, fmt __VA_ARGS__)
__assert(__func__, __LINE__, 0 /* once */, fmt, ## __VA_ARGS__)
extern void __assert(const char *func, int line, int forever,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment