From: Ricardo Garcia Date: Mon, 24 Jun 2019 09:22:56 +0000 (+0200) Subject: Enable strong-typed DE_LENGTH_OF_ARRAY for every compiler X-Git-Tag: upstream/1.3.5~2005 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=12138e34fbea5bf687d0ae02cceb0bb282374a26;p=platform%2Fupstream%2FVK-GL-CTS.git 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 --- 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