Hello all,
I'm trying to build some common code (across many compilers), and I want to conditionally change that code depending on what compiler is building it (i.e. things like certain data types, includes, etc.). I have the following flags already:
- for GCC builds, I can check if __GNUC__ is defined
- for IAR builds, I can check if __ICCARM__ is defined
- for Microsfot Visual C builds, I can check if _MSC_VER is defined
For xTIMEcomposer/xcc builds, what #define can I check?
#define to tell I'm compiling in xTIMEcomposer/xcc
-
- New User
- Posts: 3
- Joined: Fri Mar 14, 2014 10:11 pm
-
- XCore Addict
- Posts: 158
- Joined: Thu Mar 20, 2014 8:04 am
Did you try this?
#ifdef __XC__
..
..
#endif
#ifdef __XC__
..
..
#endif
-
- XCore Expert
- Posts: 844
- Joined: Sun Jul 11, 2010 1:31 am
You should not normally test which compiler is used; this
just leads to an unmaintainable mess, and breaks for all
compilers and compiler versions you haven't tested (including
future versions). Instead, you should test for the exact
feature you rely on.
That said, you probably want __clang__ or XCC_VERSION_MAJOR.
Try(or create an empty file and use that, if your OS/shell
is limited).
just leads to an unmaintainable mess, and breaks for all
compilers and compiler versions you haven't tested (including
future versions). Instead, you should test for the exact
feature you rely on.
That said, you probably want __clang__ or XCC_VERSION_MAJOR.
Try
Code: Select all
xcc -E -dM -xc /dev/null
is limited).
-
- New User
- Posts: 3
- Joined: Fri Mar 14, 2014 10:11 pm
Thanks for the help, XCC_VERSION_MAJOR is what I am looking for. Much appreciated.