In addition to variadic macros, WCPL supports the generic construct that is
traditionally used in so-called cover macros that expand to calls of different
functions based on types of their argument(s). The construct itself does not have
to be used in macros, although in practice it rarely appears anywhere else.
The usual C11 syntax for the generic construct when used in a macro looks
something like this:
WCPL supports this syntax, provided that the default association, if present,
is the last one in the list. The _Generic keyword may also be spelled as generic.
If C compatibility is not a concern, a WCPL alternative switch-like syntax can be used
(note that newline-escaping backslashes are optional in BCPL):
This syntax supports one extra WCPL-specific feature: generic dispatch based on
argument count. It uses the same countof(...) construct that was described in the
previous posts:
The examples below come from WCPL’s <sys/intrs.h> header:
The last four macros use generic dispatch to ensure that no automatic
promotions take place; the compiler will signal an error if a wrong-sized
integer or floating-point expression is used as an argument to the
corresponding builtin.