|Synopsis:||Don't reference the name of an array|
One should take care that an array variable is a pointer to the first element of the array. This can lead to subtle unintended incorrect usage and crashes as shown in the example below:
const DWORD mv_dwReadEventLogBufferSize = 64 * 1024; // All records from the event log can be read now. BYTE abyBuffer[mv_dwReadEventLogBufferSize]; // EVENTLOGRECORD defined in winnt.h EVENTLOGRECORD* pEventLogRecord = (EVENTLOGRECORD*) &abyBuffer; // Compiles fine but is wrong. Variable 'pEventLogRecord' contains one indirection too many.
It should have been as follows (two choices):
EVENTLOGRECORD* pEventLogRecord = (EVENTLOGRECORD*) abyBuffer; // OK EVENTLOGRECORD* pEventLogRecord = (EVENTLOGRECORD*) &abyBuffer; // OK