I just found out that this is illegal in C++ (but legal in C):
#include
#include
#define ARRAY_LENGTH(A) (sizeof(A) / sizeof
Dan Saks wrote about this in 1995, during the lead up to C++ standardisation:
The committees decided that functions such as this, that accept a pointer or reference to an array with unknown bound, complicate declaration matching and overload resolution rules in C++. The committees agreed that, since such functions have little utility and are fairly uncommon, it would be simplest to just ban them. Hence, the C++ draft now states:
If the type of a parameter includes a type of the form pointer to array of unknown bound of T or reference to array of unknown bound of T, the program is ill-formed.