So you build your BSP and it fails with an error like:
C2065:  'dpCurSettings' : undeclared identifier
Or
C2065: 'ZONE_INIT' : undeclared identifier
The easy answer is that you haven’t declared the variables, but the last time you built the BSP it built okay, so how could it be that all of a sudden there are undeclared variables?
The most likely reason is that you are building a debug build and you had previously been building a retail or release build. The difference is explained in Platform Builder: RETAILMSG vs. DEBUGMSG.   That explains it, but let’s fix it.
The problem is that when you build a debug build, you need to have some supporting code in your dll or exe. The first error says that dpCurSettings is undeclared.  The reason is that your code must declare and initialize a structure named dpCurSettings. If your code already declares  and initializes dpCurSettings, then the problem is that one of the files you are building needs to have an extern declaration available.
Here is an example of declaring and initializing dpCurSettings:
#ifdef DEBUG
DBGPARAM dpCurSettings = {
                TEXT("XXX Driver"),
                {
                                TEXT("Init"),
                                TEXT("Open"),
                                TEXT("Read"),
                                TEXT("Write"),
                                TEXT("Close"),
                                TEXT("Ioctl"),
                                TEXT("Thread"),
                                TEXT("Events"),
                                TEXT("CritSec"),
                                TEXT("Alloc"),
                                TEXT("Function"),
                                TEXT("Warning"),
                                TEXT("Error"),
                                NULL,
                                NULL,
                                NULL
                },
                0x00000001
};
#endif
 
The structure dpCurSettings is used by the OS to define strings that are displayed when changing the debug zones. These strings are passed to Platform Builder which then displays them when changing the debug mask using Target\CE Debug Zones. The last element, ulZoneMask, of the structure is a mask used to enable and disable debug messages, in this case only the Init debug messages will be output.
The error message indicating ZONE_INIT comes from a line in the code that looks like this:
DEBUGMSG( ZONE_INIT, (TEXT(“Initializing\n”)));
Where ZONE_INIT hasn’t yet been defined. ZONE_INIT should be a macro defined like:
                #define ZONE_INIT DEBUGZONE( 0)
Which uses the DEBUGZONE macro. The DEBUGZONE macro uses dpCurSettings. ulZoneMask anded with the value, in this case one, to “return” a value that is either set or not set. If the value is set, then the DEBUGMSG will output the string.
Copyright © 2009 – Bruce Eitman
All Rights Reserved