Calico
macros.h File Reference

Miscellaneous utility macros. More...

Macros

#define cal_cat(x, y)
 Concatenate two tokens. More...
 
#define cal_cmp(ctx, x, y)
 Compare two values, returning a negative value if less than, positive value if greater than, and zero if equal. More...
 
#define cal_cond(cond)
 Expand to the first argument if the condition is 1, or the second argument if the condition is 0. More...
 
#define cal_cond_ndebug(x, y)
 Expand to the first argument if NDEBUG is defined. More...
 
#define CAL_FUNC
 Expand to __func__ if available, else NULL. More...
 
#define cal_max(x, y)
 Calculate the maximum of two values. More...
 
#define cal_min(x, y)
 Calculate the minimum of two values. More...
 
#define cal_minlog2(x)
 Obtain a lower bound on the logarithm of a number.
 
#define CAL_NOARG
 A macro that expands to nothing. More...
 
#define cal_pcmp(ctx, x, y)
 Compare two values pointed by the given pointers, returning a negative value if less than, positive value if greater than, and zero if equal. More...
 
#define cal_pstrcmp(ctx, x, y)
 Compare two null-terminated strings pointed by the given pointers using strcmp. More...
 
#define cal_stringify(x)
 Convert an expression into a string literal. More...
 
#define CAL_WARNUNUSED
 If available, expand to a built-in function attribute that warns if the function is called without using its result. More...
 

Detailed Description

Miscellaneous utility macros.

This header can be included multiple times.

Macro Definition Documentation

#define cal_cat (   x,
 
)

Concatenate two tokens.

#define cal_cmp (   ctx,
  x,
 
)

Compare two values, returning a negative value if less than, positive value if greater than, and zero if equal.

#define cal_cond (   cond)

Expand to the first argument if the condition is 1, or the second argument if the condition is 0.

The behavior is unspecified if the condition is neither 1 nor 0.

Usage: cal_cond(condition)(value_if_1, value_if_0)

#define cal_cond_ndebug (   x,
 
)

Expand to the first argument if NDEBUG is defined.

Otherwise, expand to the second argument.

#define CAL_FUNC

Expand to __func__ if available, else NULL.

#define cal_max (   x,
 
)

Calculate the maximum of two values.

#define cal_min (   x,
 
)

Calculate the minimum of two values.

#define CAL_NOARG

A macro that expands to nothing.

Useful if you want to pass nothing to the argument of a function-like macro, since they are forbidden in older versions of C and C++.

#define cal_pcmp (   ctx,
  x,
 
)

Compare two values pointed by the given pointers, returning a negative value if less than, positive value if greater than, and zero if equal.

#define cal_pstrcmp (   ctx,
  x,
 
)

Compare two null-terminated strings pointed by the given pointers using strcmp.

#define cal_stringify (   x)

Convert an expression into a string literal.

#define CAL_WARNUNUSED

If available, expand to a built-in function attribute that warns if the function is called without using its result.