Author: cwittich Date: Mon Sep 7 08:08:01 2015 New Revision: 69080 URL: http://svn.reactos.org/svn/reactos?rev=69080&view=rev Log: [XDK] add cpp security checks for RTL_NUMBER_OF_V2/ARRAYSIZE
Modified: trunk/reactos/include/xdk/ntbasedef.h Modified: trunk/reactos/include/xdk/ntbasedef.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/xdk/ntbasedef.h?rev=69080&r1=69079&r2=69080&view=diff ============================================================================== --- trunk/reactos/include/xdk/ntbasedef.h [iso-8859-1] (original) +++ trunk/reactos/include/xdk/ntbasedef.h [iso-8859-1] Mon Sep 7 08:08:01 2015 @@ -680,8 +680,11 @@ #define RTL_NUMBER_OF_V2(A) \ (({ int _check_array_type[__builtin_types_compatible_p(typeof(A), typeof(&A[0])) ? -1 : 1]; (void)_check_array_type; }), \ RTL_NUMBER_OF_V1(A)) -#else - /// \todo implement security checks for cplusplus / MSVC +#elif defined(__cplusplus) + template <typename T, size_t N> + char (& SAFE_RTL_NUMBER_OF(T (&)[N]))[N]; + #define RTL_NUMBER_OF_V2(A) sizeof(SAFE_RTL_NUMBER_OF(A)) +#else #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A) #endif