I am working on an industry security product that requires a very quick launch time. I am trying to follow the industry standard for outputting an ASCII file. To speed up this step of formatting the file, I used #define to create multiple arrays of characters in static memory. Here is a small section, for example:
#define COMTRADE_STATION_ID "Station Name,Device ID,1999\r\n"
#define COMTRADE_CHANNEL_COUNT "10,10A,0D\r\n"
#define COMTRADE_FREQUENCY "60\r\n"
#define COMTRADE_FILE_TYPE "BINARY\r\n1\r\n"
struct TS_ComtradeConfig
{
const char StationID[sizeof(COMTRADE_STATION_ID)];
const char ChannelCount[sizeof(COMTRADE_CHANNEL_COUNT)];
char Frequency[sizeof(COMTRADE_FREQUENCY)];
const char FileType[sizeof(COMTRADE_FILE_TYPE)];
};
TS_ComtradeConfig ConfigFile =
{
{COMTRADE_STATION_ID},
{COMTRADE_CHANNEL_COUNT},
{COMTRADE_FREQUENCY},
{COMTRADE_FILE_TYPE}
};
And here is some basic code that I used to print it out.
for(int nIndex = 0; nIndex < sizeof(ConfigFile); nIndex++)
{
printf("%c", ((char*)(ConfigFile.StationID))[nIndex]);
}
char ConfigFile , char , , . , #define . ? ?