Are there macros or builtins that can return the length of arrays at compile time in GCC?
For example:
int array[10];
For which:
sizeof(array) == 40
???(array) == 10
Update0
I might just point out that doing this in C++ is trivial. One can build a template that returns the number inside []
. I was certain that I'd once found a lengthof
and dimof
macro/builtin in the Visual C++ compiler but cannot find it anymore.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…