mirror of https://github.com/ArduPilot/ardupilot
7ba6f92eb5
Now that most places in the code use the ARRAY_SIZE macro instead of coding it by hand, let's use some type safety in its definition. This is a C++ version of similar macros used in kmod, Linux kernel and the source of them, ccan. A C++ version like this is used in V8 (the JS engine) and other open source projects. The main benefit of this version is that you get a compile error if you pass in a variable that's not an array. For example, Bla y[10]; Bla *y_ptr = y; void foo(Bla x[]) { // build error since x[] decay to a pointer in function // parameter for (int i = 0; i < ARRAY_SIZE(x); i++) { ... } // build error since y_ptr is not an array for (int i = 0; i < ARRAY_SIZE(y_ptr); i++) { ... } } I added the additional specialization to allow arrays of size 0. |
||
---|---|---|
.. | ||
examples/AP_Common | ||
AP_Common.cpp | ||
AP_Common.h | ||
AP_Test.h | ||
Arduino.h | ||
c++.cpp | ||
keywords.txt |