02-06-2014 02:27 AM
I am porting a code which should compile for both Linux on a desktop computer and Linux on Zynq.
I am trying to find a predefined preprocessor macro I could use to differentiate between compiling natively for Linux or when cross-compiling for Zynq.
I am searching something like __zynq__ so I can #ifdef the code with it.
Any direct answer or pointers to the right documentation is welcome.
02-10-2014 04:04 AM
You can try to run the following command
arm-xilinx-eabi-gcc -E -dM <input.c> for Standalone OS
arm-xilinx-linux-gnueabi-gcc -E -dM <input.c> for Linux OS
01-26-2016 09:29 PM
This is old, but anyway, to answer the question.
There's two concepts here:
- differentiating by architecture, e.g. ARM (Zynq) vs x64 (desktop)
- differentiating by operating system e.g. Linux
It sounds like you're interested in differentiating by architecture. The Zynq cross compiler defines:
which is what you'd be after.
(Unfortunately, diffing the output of the commands in the other answer won't highlight this, because they're both Zynq cross compilers.)
The native machine compiler might define __x86__ or __x86_64__ or whatever's appropriate.
For interest's sake, to tell if you're looking for the Linux OS, look for:
And there is no predefined macro for the Xilinx standalone OS compiler, unfortunately. See https://forums.xilinx.com/t5/Embedded-Development-Tools/C-Preprocessor-predefined-macro-for-Xilinx-standalone-OS/m-p/677536#M38858.