UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor amaye
Visitor
2,858 Views
Registered: ‎01-15-2008

Predefined macros for arm-xilinx-Linux-gnueabi-x

Gentlemen,

 

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.

 

Best Regards,

Arnaud

0 Kudos
2 Replies
Xilinx Employee
Xilinx Employee
2,825 Views
Registered: ‎08-02-2007

Re: Predefined macros for arm-xilinx-Linux-gnueabi-x

Hi,

 

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

 

--Hem

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Adventurer
Adventurer
1,101 Views
Registered: ‎09-19-2014

Re: Predefined macros for arm-xilinx-Linux-gnueabi-x

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:

__arm__

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:

__linux__

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.

0 Kudos