Monday, March 19, 2012

To list MicroBlaze gcc Predefined Macros

I was searching for any predefined macros that define the version information in GCC for MicroBlaze. But, I do not get any information on the web. I was looking for any macros like EDK_VERSION, EDK_VER, predefined macros related to -mcpu=cpu-type option such as CPU_MAJOR, CPU_MINOR, CPU_VER, CPU_VERSION. No information at all. Finally, I found a good command to display all of the predefined macros in gcc.

To view all the of predefined macros of GCC, input the following command:

$ mb-gcc -E -dM <your C or assembly file>[ENTER]

    -dM : Output only the predefined macros enabled at completion of preprocess
    -E : Stop after the preprocess is over

Predefined macros of GCC are displayed as follows:

Example:

#define __GNUC__ 4
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __LONG_MAX__ 2147483647L
#define __WCHAR_TYPE__ int
#define __INT_MAX__ 2147483647
#define __STDC__ 1
#define __MICROBLAZE__ 1
#define __BIG_ENDIAN__ 1
#define _BIG_ENDIAN 1
#define __VERSION__ "4.1.2 20070214 (Xilinx 13.4 Build EDK_O.87 25 Nov 2011)"

I found that the version information is available only as string as shown above. So, it is impossible to conditionally compile or assemble the source for MicroBlaze according to the EDK or CPU version.

Though, I have used mb-gcc here, it can be any GCC or even GCC for Xilinx PowerPC too!
Put your comments to improve this!

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.