Page 1 of 1

Save User Params Question

Posted: Tue May 12, 2009 8:42 am
by seulater
NB gives us an example of how to save user paramters to flash.
it works well, however i need to declare it globally. i have other included files that i would like to access *pData. i have tried and googled but not having much luck in doing so.

Below is the code snipped from that exmple. I just need to access *pData from another *.cpp file.


Code: Select all

struct NV_SettingsStruct
{
      DWORD VerifyKey;
      WORD  nvWord;
      char  nvChar;
      BYTE  nvByte;
};
NV_SettingsStruct NV_Settings;

NV_SettingsStruct *pData = ( NV_SettingsStruct * ) GetUserParameters();

Re: Save User Params Question

Posted: Tue May 12, 2009 8:54 am
by stevep
Declare pData as extern in the other cpp files where you want to access it.

Code: Select all

extern NV_SettingsStruct *pData;

Re: Save User Params Question

Posted: Tue May 12, 2009 9:05 am
by seulater
ya, tired that an i get this error.

"expected initializer before '*' token"

Re: Save User Params Question

Posted: Tue May 12, 2009 9:13 am
by stevep
The second .cpp file can't get to the structure definition. Try moving the definition to the header and then #include it in the second .cpp.