Let's take a look at this template.
Extern "C " // Templates Cannot Be Declared to Have 'C' Linkage
Template
Char (* RTLPNUMBEROF (UNALIGNED T (&) [N])) [N];
Want to know what this Template is used? Its purpose is not to generate a callable template function, and there is no import at all. No one needs to call it.
Do you consider the arraysize macro macro with type check? Arraysize general definition is: #define arraysize (x) (sizeof (x) / sizeof ((x) [0]))
But this macro will bring catastrophic consequences in the following code, and the compiler will not have Warning. (Though None Will Make this Type of Mistake In General)
Struct foo {char _ch [10];}; foo * pfoo; arraysize (pfoo); // will == 0 How to solve it? The following is seen from Winnt.h: // Attempts to Pass Pointers Instead of Arrays to this Macro Result In Compile Time Errors. // That Is The Point. // Extern "C " // Templates Cannot Be Declared to Have 'C' Linkage Template Char (* RTLPNumberof (Unaligned T (&) [N])) [n]; #define rtl_number_of_v2 (a) (Sizeof (* RTLPNumberof (a))) ... # Define arraysize (a) RTL_NUMBER_OF_V2 (a) is really "not can't do, only if you can't think." However, this thing is a little Hack. It is too difficult to understand, and the comment is below. // RtlpNumberOf is a function that a reference to an array of N Ts // // typedef T array_of_T [N] takes;. // typedef array_of_T & reference_to_array_of_T; // // RtlpNumberOf returns a reference to an array of N chars. // // typedef char array_of_char [N]; // typedef T3 & reference_to_array_of_char; // // sizeof (array_of_char) == N // sizeof (reference_to_array_of_char) == N // // reference_to_array_of_char RtlpNumberOf (reference_to_array_of_T); // // We Never Even Call RTLPNUMBEROF, We Just Take The size of it do not Even IPLEMENT RTLPNUMBEROF, We Just Decare It. // The above is my own understanding, I don't know if it is correct, welcome to discuss.