The C++ strong-typed version of DE_LENGTH_OF_ARRAY should work with
every C++ compiler. This commit removes the restriction of being used
only with the Microsoft compiler.
Components: Framework
VK-GL-CTS issue: 1848
Change-Id: Id28c02ab4dfecefa84093578afca0da50b0bdd65
/*#define DE_VALGRIND_BUILD*/
/** Length of array. C++ version does compile time check that passed value is an array reference. */
-#if defined(__cplusplus) && (DE_COMPILER == DE_COMPILER_MSC)
+#if defined(__cplusplus)
+ // deArraySizeHelper is a function that receives a reference to an array of N elements of type T and returns a reference to an
+ // array of N chars. This forces the compiler to check the argument is an actual array and not some other type implementing
+ // operator[]. The actual function is never defined anywhere, but taking the sizeof() of the result is allowed and equal to N.
template <typename T, size_t N> char (&deArraySizeHelper(T (&array)[N]))[N];
# define DE_LENGTH_OF_ARRAY(ARRAY) ((int)(sizeof(deArraySizeHelper(ARRAY))))
#else