From 12138e34fbea5bf687d0ae02cceb0bb282374a26 Mon Sep 17 00:00:00 2001 From: Ricardo Garcia Date: Mon, 24 Jun 2019 11:22:56 +0200 Subject: [PATCH] Enable strong-typed DE_LENGTH_OF_ARRAY for every compiler 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 --- framework/delibs/debase/deDefs.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/delibs/debase/deDefs.h b/framework/delibs/debase/deDefs.h index bff057f..4edc5e8 100644 --- a/framework/delibs/debase/deDefs.h +++ b/framework/delibs/debase/deDefs.h @@ -255,7 +255,10 @@ typedef void (*deFunctionPtr) (void); /*#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 char (&deArraySizeHelper(T (&array)[N]))[N]; # define DE_LENGTH_OF_ARRAY(ARRAY) ((int)(sizeof(deArraySizeHelper(ARRAY)))) #else -- 2.7.4