Technical Note : SLE0006
Author : Scott Evans
Created/Modified : 11/9/98
Description : Useful compiler symbols 
 
 This technical note describes some of the GNU compiler symbols which can be used in your C programs.

All the symbols have the following format __SYMBOL__.
 

Time and date

There are two compiler symbols which return a string containing the time and date when the source file was compiled. They are __DATE__ and __TIME__. These can be used to time stamp your code.

The following example will display the build time of the program.

Example

printf(“Build time : %s %s\n”,__DATE__,__TIME__);
 

Function names

The symbol __FUNCTION__ can be used to return the string containing the name of the current function. This can be useful when printing errors. Following is an example.

#define PrintStatus(s)
 printf(“%s : %s”,__FUNCTION__,s)

int InitSoundData(SOUND_EFFECT *se,u_byte *vh,u_byte *vb)
{
  word vabid;
 
     // Transfer sound data, wait for data to be transfered
 
     vabid=SsVabTransfer(vh,vb,-1,SS_WAIT_COMPLETED);

 if(vabid<0)
  PrintStatus(“Failed\n”);
 Else
  PrintStatus(“Completed\n”);

 Return(vabid);
}

So if vabid is less than 0 the following will be output.

InitSoundData : Failed

Otherwise the output will be

InitSoundData : Completed
 

GNU compiler

The symbol __GNUC__ is defined when you are using GNU C. The symbol __STDC__ is defined when using standard C.

These can be useful if you are using GNU extensions to C.

Including binary data

You can include binary data in C source files with the following method.

u_byte binary_data[]={
 #include “binary.dat”
};

This is basically equivalent to the following assembly language code except the contents of binary.dat needs to be in the following format.

0x100,0x200,0x300,0x400 etc..

I use a very simple program to convert binary files into this format.

                   global binary_data

binary_data: incbin “binary.dat”

Make note that large files will slow down the compiler.
 

This document in word format.
This document in text format.