EmbeddedRelated.com
Forums

Compiler autodetection?

Started by Rolf F. April 22, 2004
Hi,

i'm using defines and ifs/elses for compiling with different compilers 
and to automatize this i'm looking for compiler (or preprocessor) 
dependent defines .
Does someone has  a list of macros/functions or something else which is 
only availible with one compiler/preprocessor?

Rolf



Beginning Microcontrollers with the MSP430

"Rolf F." <rolf.freitag@rolf...> writes:

> i'm using defines and ifs/elses for compiling
with different compilers
> and to automatize this i'm looking for compiler (or preprocessor)
> dependent defines .
> Does someone has  a list of macros/functions or something else which is
> only availible with one compiler/preprocessor?

Hi!

For the IAR compilers you can use check the symbol
__IAR_SYSTEMS_ICC__.  It is defined in all our compilers.

If you would like to distinguish between different IAR compilers then
the moders one sets e.g. __ICC430__ or __ICCAVR__ for our msp430 or
avr compiler, respectively.  Unfortunately, this is not defined for
the old compiler.  (The older ones used a now depreciated macro
__TID__ for this.  It is still present in all our compilers but we do
not recommend that you use it for code that is not intended to be
runed on older compiler.  However, in this case it is appropriate.)

To find the exact compiler version you can use the macro __VER__,
which is an integer on the form: MajorVersioNumber*100 +
MinorVersioNumber.  For example for V3.10 this has the value 310.

So, to put everything together:


#ifdef __IAR_SYSTEMS_ICC__
/* This is an IAR Compiler. */

#  if (((__TID__ >> 8) & 0x7f) == 43)
/* This is the IAR MSP430 compiler. */

#    if __VER__ < 200

/* V1.xx of the compiler. */

#    else

/* V2.xx, or newer, of the compiler. */

#    endif

#  elif (((__TID__ >> 8) & 0x7f) == 45)
/* This is the IAR CR16C compiler. */

#  elif (((__TID__ >> 8) & 0x7f) == 85)
/* This is the IAR V850 compiler. */

#  else
/* Unknown IAR compiler. */

#  endif

#else
/* This is not an IAR compiler. */

#endif

    -- Anders Lindgren, IAR Systems
-- 
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.

From mspgcc faq (http://mspgcc.sourceforge.net/manual/x863.html):

The compiler defines some symbols, so the header files and source code 
can easily behave in an MCU dependant manner. These are: 

MSP430

__MSP430__

__MSP430_xxx__, where xxx is replaced by the number of the MCU variant 
(e.g. __MSP430_149__ is defined for the msp430x149).



Patrik




--- In msp430@msp4..., Anders Lindgren <andersl@i...> wrote:
> 
> "Rolf F." <rolf.freitag@d...> writes:
> 
> > i'm using defines and ifs/elses for compiling with different 
compilers
> > and to automatize this i'm looking for
compiler (or preprocessor)
> > dependent defines .
> > Does someone has  a list of macros/functions or something else 
which is
> > only availible with one
compiler/preprocessor?
> 
> Hi!
> 
> For the IAR compilers you can use check the symbol
> __IAR_SYSTEMS_ICC__.  It is defined in all our compilers.
> 
> If you would like to distinguish between different IAR compilers 
then
> the moders one sets e.g. __ICC430__ or __ICCAVR__
for our msp430 or
> avr compiler, respectively.  Unfortunately, this is not defined for
> the old compiler.  (The older ones used a now depreciated macro
> __TID__ for this.  It is still present in all our compilers but we 
do
> not recommend that you use it for code that is not
intended to be
> runed on older compiler.  However, in this case it is appropriate.)
> 
> To find the exact compiler version you can use the macro __VER__,
> which is an integer on the form: MajorVersioNumber*100 +
> MinorVersioNumber.  For example for V3.10 this has the value 310.
> 
> So, to put everything together:
> 
> 
> #ifdef __IAR_SYSTEMS_ICC__
> /* This is an IAR Compiler. */
> 
> #  if (((__TID__ >> 8) & 0x7f) == 43)
> /* This is the IAR MSP430 compiler. */
> 
> #    if __VER__ < 200
> 
> /* V1.xx of the compiler. */
> 
> #    else
> 
> /* V2.xx, or newer, of the compiler. */
> 
> #    endif
> 
> #  elif (((__TID__ >> 8) & 0x7f) == 45)
> /* This is the IAR CR16C compiler. */
> 
> #  elif (((__TID__ >> 8) & 0x7f) == 85)
> /* This is the IAR V850 compiler. */
> 
> #  else
> /* Unknown IAR compiler. */
> 
> #  endif
> 
> #else
> /* This is not an IAR compiler. */
> 
> #endif
> 
>     -- Anders Lindgren, IAR Systems
> -- 
> Disclaimer: Opinions expressed in this posting are strictly my own 
and
> not necessarily those of my employer.


Hi,

thanks, but which header files have to be included for these symbols?

Rolf


rotamat2000 schrieb:

>>From mspgcc faq
(http://mspgcc.sourceforge.net/manual/x863.html):
>
>The compiler defines some symbols, so the header files and source code 
>can easily behave in an MCU dependant manner. These are: 
>
>MSP430
>
>__MSP430__
>
>__MSP430_xxx__, where xxx is replaced by the number of the MCU variant 
>(e.g. __MSP430_149__ is defined for the msp430x149).
>
>
>
>Patrik
>
>
>
>
>--- In msp430@msp4..., Anders Lindgren <andersl@i...> wrote:
>  
>
>>"Rolf F." <rolf.freitag@d...> writes:
>>
>>    
>>
>>>i'm using defines and ifs/elses for compiling with different 
>>>      
>>>
>compilers
>  
>
>>>and to automatize this i'm looking for compiler (or
preprocessor)
>>>dependent defines .
>>>Does someone has  a list of macros/functions or something else 
>>>      
>>>
>which is
>  
>
>>>only availible with one compiler/preprocessor?
>>>      
>>>
>>Hi!
>>
>>For the IAR compilers you can use check the symbol
>>__IAR_SYSTEMS_ICC__.  It is defined in all our compilers.
>>
>>If you would like to distinguish between different IAR compilers 
>>    
>>
>then
>  
>
>>the moders one sets e.g. __ICC430__ or __ICCAVR__ for our msp430 or
>>avr compiler, respectively.  Unfortunately, this is not defined for
>>the old compiler.  (The older ones used a now depreciated macro
>>__TID__ for this.  It is still present in all our compilers but we 
>>    
>>
>do
>  
>
>>not recommend that you use it for code that is not intended to be
>>runed on older compiler.  However, in this case it is appropriate.)
>>
>>To find the exact compiler version you can use the macro __VER__,
>>which is an integer on the form: MajorVersioNumber*100 +
>>MinorVersioNumber.  For example for V3.10 this has the value 310.
>>
>>So, to put everything together:
>>
>>
>>#ifdef __IAR_SYSTEMS_ICC__
>>/* This is an IAR Compiler. */
>>
>>#  if (((__TID__ >> 8) & 0x7f) == 43)
>>/* This is the IAR MSP430 compiler. */
>>
>>#    if __VER__ < 200
>>
>>/* V1.xx of the compiler. */
>>
>>#    else
>>
>>/* V2.xx, or newer, of the compiler. */
>>
>>#    endif
>>
>>#  elif (((__TID__ >> 8) & 0x7f) == 45)
>>/* This is the IAR CR16C compiler. */
>>
>>#  elif (((__TID__ >> 8) & 0x7f) == 85)
>>/* This is the IAR V850 compiler. */
>>
>>#  else
>>/* Unknown IAR compiler. */
>>
>>#  endif
>>
>>#else
>>/* This is not an IAR compiler. */
>>
>>#endif
>>
>>    -- Anders Lindgren, IAR Systems
>>-- 
>>Disclaimer: Opinions expressed in this posting are strictly my own 
>>    
>>
>and
>  
>
>>not necessarily those of my employer.
>>    
>>
>
>
>
>
>.
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>  
>



One assumes they are predefined like __STDC__, just as ours are in
CrossWorks.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors 

> -----Original Message-----
> From: Rolf F. [mailto:rolf.freitag@rolf...] 
> Sent: 22 April 2004 11:11
> To: msp430@msp4...
> Subject: Re: [msp430] Re: Compiler autodetection?
> 
> 
> Hi,
> 
> thanks, but which header files have to be included for these symbols?
> 
> Rolf
> 
> 
> rotamat2000 schrieb:
> 
> >>From mspgcc faq (http://mspgcc.sourceforge.net/manual/x863.html):
> >
> >The compiler defines some symbols, so the header files and 
> source code
> >can easily behave in an MCU dependant manner. These are: 
> >
> >MSP430
> >
> >__MSP430__
> >
> >__MSP430_xxx__, where xxx is replaced by the number of the 
> MCU variant
> >(e.g. __MSP430_149__ is defined for the msp430x149).
> >
> >
> >
> >Patrik
> >
> >
> >
> >
> >--- In msp430@msp4..., Anders Lindgren <andersl@i...> wrote:
> >  
> >
> >>"Rolf F." <rolf.freitag@d...> writes:
> >>
> >>    
> >>
> >>>i'm using defines and ifs/elses for compiling with
different
> >>>      
> >>>
> >compilers
> >  
> >
> >>>and to automatize this i'm looking for compiler (or
preprocessor) 
> >>>dependent defines . Does someone has  a list of 
> macros/functions or 
> >>>something else
> >>>      
> >>>
> >which is
> >  
> >
> >>>only availible with one compiler/preprocessor?
> >>>      
> >>>
> >>Hi!
> >>
> >>For the IAR compilers you can use check the symbol 
> >>__IAR_SYSTEMS_ICC__.  It is defined in all our compilers.
> >>
> >>If you would like to distinguish between different IAR compilers
> >>    
> >>
> >then
> >  
> >
> >>the moders one sets e.g. __ICC430__ or __ICCAVR__ for our msp430 or

> >>avr compiler, respectively.  Unfortunately, this is not defined for

> >>the old compiler.  (The older ones used a now depreciated macro 
> >>__TID__ for this.  It is still present in all our compilers but we
> >>    
> >>
> >do
> >  
> >
> >>not recommend that you use it for code that is not intended to be 
> >>runed on older compiler.  However, in this case it is appropriate.)
> >>
> >>To find the exact compiler version you can use the macro __VER__, 
> >>which is an integer on the form: MajorVersioNumber*100 + 
> >>MinorVersioNumber.  For example for V3.10 this has the value 310.
> >>
> >>So, to put everything together:
> >>
> >>
> >>#ifdef __IAR_SYSTEMS_ICC__
> >>/* This is an IAR Compiler. */
> >>
> >>#  if (((__TID__ >> 8) & 0x7f) == 43)
> >>/* This is the IAR MSP430 compiler. */
> >>
> >>#    if __VER__ < 200
> >>
> >>/* V1.xx of the compiler. */
> >>
> >>#    else
> >>
> >>/* V2.xx, or newer, of the compiler. */
> >>
> >>#    endif
> >>
> >>#  elif (((__TID__ >> 8) & 0x7f) == 45)
> >>/* This is the IAR CR16C compiler. */
> >>
> >>#  elif (((__TID__ >> 8) & 0x7f) == 85)
> >>/* This is the IAR V850 compiler. */
> >>
> >>#  else
> >>/* Unknown IAR compiler. */
> >>
> >>#  endif
> >>
> >>#else
> >>/* This is not an IAR compiler. */
> >>
> >>#endif
> >>
> >>    -- Anders Lindgren, IAR Systems
> >>--
> >>Disclaimer: Opinions expressed in this posting are strictly my own 
> >>    
> >>
> >and
> >  
> >
> >>not necessarily those of my employer.
> >>    
> >>
> >
> >
> >
> >
> >.
> >
> > 
> >Yahoo! Groups Links
> >
> >
> >
> > 
> >
> >
> >  
> >
> 
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor 
> ---------------------~--> Buy Ink Cartridges or Refill Kits 
> for your HP, Epson, Canon or Lexmark Printer at MyInks.com.  
> Free s/h on orders $50 or more to the US & Canada. 
http://www.c1tracking.com/l.asp?cidU11
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/CFFolB/TM
---------------------------------~->

.

 
Yahoo! Groups Links



 


That's Right.
In my project I use the following defines:

#ifdef __IAR_SYSTEMS_ICC
    #define __COMPILER_IAR
#endif
#ifdef  __MSP430__
    #define __COMPILER_GCC
#endif


Patrik


--- In msp430@msp4..., "Paul Curtis" <plc@r...> wrote:
> One assumes they are predefined like __STDC__,
just as ours are in
> CrossWorks.
> 
> --
> Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors 
> 
> > -----Original Message-----
> > From: Rolf F. [mailto:rolf.freitag@d...] 
> > Sent: 22 April 2004 11:11
> > To: msp430@msp4...
> > Subject: Re: [msp430] Re: Compiler autodetection?
> > 
> > 
> > Hi,
> > 
> > thanks, but which header files have to be included for these 
symbols?
> > 
> > Rolf
> > 
> > 
> > rotamat2000 schrieb:
> > 
> > >>From mspgcc faq
(http://mspgcc.sourceforge.net/manual/x863.html)
:
> > >
> > >The compiler defines some symbols, so the header files and 
> > source code
> > >can easily behave in an MCU dependant manner. These are: 
> > >
> > >MSP430
> > >
> > >__MSP430__
> > >
> > >__MSP430_xxx__, where xxx is replaced by the number of the 
> > MCU variant
> > >(e.g. __MSP430_149__ is defined for the msp430x149).
> > >
> > >
> > >
> > >Patrik
> > >
> > >
> > >
> > >
> > >--- In msp430@msp4..., Anders Lindgren <andersl@i...> 
wrote:
> > >  
> > >
> > >>"Rolf F." <rolf.freitag@d...> writes:
> > >>
> > >>    
> > >>
> > >>>i'm using defines and ifs/elses for compiling with
different
> > >>>      
> > >>>
> > >compilers
> > >  
> > >
> > >>>and to automatize this i'm looking for compiler (or 
preprocessor) 
> > >>>dependent defines . Does someone
has  a list of 
> > macros/functions or 
> > >>>something else
> > >>>      
> > >>>
> > >which is
> > >  
> > >
> > >>>only availible with one compiler/preprocessor?
> > >>>      
> > >>>
> > >>Hi!
> > >>
> > >>For the IAR compilers you can use check the symbol 
> > >>__IAR_SYSTEMS_ICC__.  It is defined in all our compilers.
> > >>
> > >>If you would like to distinguish between different IAR
compilers
> > >>    
> > >>
> > >then
> > >  
> > >
> > >>the moders one sets e.g. __ICC430__ or __ICCAVR__ for our
msp430 
or 
> > >>avr compiler, respectively. 
Unfortunately, this is not defined 
for 
> > >>the old compiler.  (The older ones
used a now depreciated macro 
> > >>__TID__ for this.  It is still present in all our compilers
but 
we
> > >>    
> > >>
> > >do
> > >  
> > >
> > >>not recommend that you use it for code that is not intended to

be 
> > >>runed on older compiler.  However, in
this case it is 
appropriate.)
> > >>
> > >>To find the exact compiler version you can use the macro 
__VER__, 
> > >>which is an integer on the form:
MajorVersioNumber*100 + 
> > >>MinorVersioNumber.  For example for V3.10 this has the value 
310.
> > >>
> > >>So, to put everything together:
> > >>
> > >>
> > >>#ifdef __IAR_SYSTEMS_ICC__
> > >>/* This is an IAR Compiler. */
> > >>
> > >>#  if (((__TID__ >> 8) & 0x7f) == 43)
> > >>/* This is the IAR MSP430 compiler. */
> > >>
> > >>#    if __VER__ < 200
> > >>
> > >>/* V1.xx of the compiler. */
> > >>
> > >>#    else
> > >>
> > >>/* V2.xx, or newer, of the compiler. */
> > >>
> > >>#    endif
> > >>
> > >>#  elif (((__TID__ >> 8) & 0x7f) == 45)
> > >>/* This is the IAR CR16C compiler. */
> > >>
> > >>#  elif (((__TID__ >> 8) & 0x7f) == 85)
> > >>/* This is the IAR V850 compiler. */
> > >>
> > >>#  else
> > >>/* Unknown IAR compiler. */
> > >>
> > >>#  endif
> > >>
> > >>#else
> > >>/* This is not an IAR compiler. */
> > >>
> > >>#endif
> > >>
> > >>    -- Anders Lindgren, IAR Systems
> > >>--
> > >>Disclaimer: Opinions expressed in this posting are strictly my

own 
> > >>    
> > >>
> > >and
> > >  
> > >
> > >>not necessarily those of my employer.
> > >>    
> > >>
> > >
> > >
> > >
> > >
> > >.
> > >
> > > 
> > >Yahoo! Groups Links
> > >
> > >
> > >
> > > 
> > >
> > >
> > >  
> > >
> > 
> > 
> > 
> > 
> > ------------------------ Yahoo! Groups Sponsor 
> > ---------------------~--> Buy Ink Cartridges or Refill Kits 
> > for your HP, Epson, Canon or Lexmark Printer at MyInks.com.  
> > Free s/h on orders $50 or more to the US & Canada. 
> http://www.c1tracking.com/l.asp?cidU11
> http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/CFFolB/TM
> 
---------------------------------~
->
> 
> .
> 
>  
> Yahoo! Groups Links


Hi,

ok,  it works :-)

Rolf

Paul Curtis schrieb:

>One assumes they are predefined like __STDC__, just
as ours are in
>CrossWorks.
>
>--
>Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
>CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors 
>
>  
>
>>-----Original Message-----
>>From: Rolf F. [mailto:rolf.freitag@rolf...] 
>>Sent: 22 April 2004 11:11
>>To: msp430@msp4...
>>Subject: Re: [msp430] Re: Compiler autodetection?
>>
>>
>>Hi,
>>
>>thanks, but which header files have to be included for these symbols?
>>
>>Rolf
>>
>>
>>rotamat2000 schrieb:
>>
>>    
>>
>>>>From mspgcc faq
(http://mspgcc.sourceforge.net/manual/x863.html):
>>>
>>>The compiler defines some symbols, so the header files and 
>>>      
>>>
>>source code
>>    
>>
>>>can easily behave in an MCU dependant manner. These are: 
>>>
>>>MSP430
>>>
>>>__MSP430__
>>>
>>>__MSP430_xxx__, where xxx is replaced by the number of the 
>>>      
>>>
>>MCU variant
>>    
>>
>>>(e.g. __MSP430_149__ is defined for the msp430x149).
>>>
>>>
>>>
>>>Patrik
>>>
>>>
>>>
>>>
>>>--- In msp430@msp4..., Anders Lindgren <andersl@i...> wrote:
>>> 
>>>
>>>      
>>>
>>>>"Rolf F." <rolf.freitag@d...> writes:
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>>>i'm using defines and ifs/elses for compiling with
different
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>compilers
>>> 
>>>
>>>      
>>>
>>>>>and to automatize this i'm looking for compiler (or
preprocessor) 
>>>>>dependent defines . Does someone has  a list of 
>>>>>          
>>>>>
>>macros/functions or 
>>    
>>
>>>>>something else
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>which is
>>> 
>>>
>>>      
>>>
>>>>>only availible with one compiler/preprocessor?
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>Hi!
>>>>
>>>>For the IAR compilers you can use check the symbol 
>>>>__IAR_SYSTEMS_ICC__.  It is defined in all our compilers.
>>>>
>>>>If you would like to distinguish between different IAR compilers
>>>>   
>>>>
>>>>        
>>>>
>>>then
>>> 
>>>
>>>      
>>>
>>>>the moders one sets e.g. __ICC430__ or __ICCAVR__ for our msp430
or 
>>>>avr compiler, respectively.  Unfortunately, this is not defined
for 
>>>>the old compiler.  (The older ones used a now depreciated macro 
>>>>__TID__ for this.  It is still present in all our compilers but
we
>>>>   
>>>>
>>>>        
>>>>
>>>do
>>> 
>>>
>>>      
>>>
>>>>not recommend that you use it for code that is not intended to
be 
>>>>runed on older compiler.  However, in this case it is
appropriate.)
>>>>
>>>>To find the exact compiler version you can use the macro
__VER__, 
>>>>which is an integer on the form: MajorVersioNumber*100 + 
>>>>MinorVersioNumber.  For example for V3.10 this has the value
310.
>>>>
>>>>So, to put everything together:
>>>>
>>>>
>>>>#ifdef __IAR_SYSTEMS_ICC__
>>>>/* This is an IAR Compiler. */
>>>>
>>>>#  if (((__TID__ >> 8) & 0x7f) == 43)
>>>>/* This is the IAR MSP430 compiler. */
>>>>
>>>>#    if __VER__ < 200
>>>>
>>>>/* V1.xx of the compiler. */
>>>>
>>>>#    else
>>>>
>>>>/* V2.xx, or newer, of the compiler. */
>>>>
>>>>#    endif
>>>>
>>>>#  elif (((__TID__ >> 8) & 0x7f) == 45)
>>>>/* This is the IAR CR16C compiler. */
>>>>
>>>>#  elif (((__TID__ >> 8) & 0x7f) == 85)
>>>>/* This is the IAR V850 compiler. */
>>>>
>>>>#  else
>>>>/* Unknown IAR compiler. */
>>>>
>>>>#  endif
>>>>
>>>>#else
>>>>/* This is not an IAR compiler. */
>>>>
>>>>#endif
>>>>
>>>>   -- Anders Lindgren, IAR Systems
>>>>--
>>>>Disclaimer: Opinions expressed in this posting are strictly my
own 
>>>>   
>>>>
>>>>        
>>>>
>>>and
>>> 
>>>
>>>      
>>>
>>>>not necessarily those of my employer.
>>>>   
>>>>
>>>>        
>>>>
>>>
>>>
>>>.
>>>
>>>
>>>Yahoo! Groups Links
>>>
>>>
>>>
>>>
>>>
>>>
>>> 
>>>
>>>      
>>>
>>
>>
>>------------------------ Yahoo! Groups Sponsor 
>>---------------------~--> Buy Ink Cartridges or Refill Kits 
>>for your HP, Epson, Canon or Lexmark Printer at MyInks.com.  
>>Free s/h on orders $50 or more to the US & Canada. 
>>    
>>
>http://www.c1tracking.com/l.asp?cidU11
>http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/CFFolB/TM
>---------------------------------~->
>
>.
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>.
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>  
>



Hi

>#ifdef __IAR_SYSTEMS_ICC__
>/* This is an IAR Compiler. */
>  
>
This works.

>#  if (((__TID__ >> 8) & 0x7f) == 43)
>/* This is the IAR MSP430 compiler. */
>
>#    if __VER__ < 200
>  
>

This does not work; it fails for the 1.26 version.

Rolf



"Rolf F." <rolf.freitag@rolf...> writes:

> Hi
>
> >#ifdef __IAR_SYSTEMS_ICC__
> >/* This is an IAR Compiler. */
> >
> >
> This works.
>
> >#  if (((__TID__ >> 8) & 0x7f) == 43)
> >/* This is the IAR MSP430 compiler. */
> >
> >#    if __VER__ < 200

How does it fail?

Try to compile the following variant -- I've added #error:s to it so
that it will report the result little bit more clearly.  I've also
added one case at the bottom, if it triggers then you can try to
change the initial #ifdef to "#if defined(__IAR_SYSTEMS_ICC__) ||
defined(__IAR_SYSTEMS_ICC)", but hopefully this will not be necessary.

When I apply this to our old compiler it reports:

#      error "V1.xx of the compiler."
-^
"def.c",9  Error[141]: #error '"V1.xx of the
compiler."'

Please let me know what happends when you compile the file.

    -- Anders

----------------------------------

#ifdef __IAR_SYSTEMS_ICC__
/* This is an IAR Compiler. */

#  if (((__TID__ >> 8) & 0x7f) == 43)
/* MSP430 */

#    if __VER__ < 200

#      error "V1.xx of the compiler."

#    else

#      error "V2.xx, or newer, of the compiler."

#    endif

#  elif (((__TID__ >> 8) & 0x7f) == 41)

#    error "cr16"

#  elif (((__TID__ >> 8) & 0x7f) == 45)

#    error "cr16c"

#  else

#    error "unknown IAR compiler"

#  endif

#endif


#if defined(__IAR_SYSTEMS_ICC) && !defined(__IAR_SYSTEMS_ICC__)
#error "Only old symbol defined"
#endif
-- 
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.

Hi,

ok, i forgott a flag in case a right compiler can be found:


#ifndef CONFIG_H
#   define CONFIG_H
// compiler autodetection
#   ifdef COMPILER_OK
#      undef COMPILER_OK
#   endif
#   ifdef __IAR_SYSTEMS_ICC__
/* This is an IAR Compiler. */
#      if (((__TID__ >> 8) & 0x7f) == 43)
/* This is the IAR MSP430 compiler. */
#         define IAR
#         if (__VER__ < 200)
/* V1.xx of the compiler. */
#            define IARV1
#            define COMPILER_OK
#         else
#            if (__VER__ < 300)
/* V2.xx of the compiler. */
#               define IARV2
#            else
#               if (__VER__ < 400)
/* V3.xx of the compiler. */
#                  define IARV3
#               endif
#            endif
#         endif
#      endif
#      if (((__TID__ >> 8) & 0x7f) == 45)
/* This is the IAR CR16C compiler. */
#         error "No MSP430 compiler."
#      else
#         if (((__TID__ >> 8) & 0x7f) == 85)
/* This is the IAR V850 compiler. */
#            error "No MSP430 compiler."
#         else
/* Unknown IAR compiler. */
#         endif
#      endif
/* This is not an IAR compiler. */
#   else
#      if defined(MSP430) && defined(__MSP430__)
/* MSPGCC */
#         define MSPGCC
#         define COMPILER_OK
#
/* MCU check */
// #ifndef __MSP430_W427__
// #  error "Wrong MCU."
// #endif
#
#      else
/* No IAR compiler, no MSPGCC */
#         error "Unknown compiler/preprocessor."
#      endif
#   endif
/* End compiler autodetection */
...
#endif

Rolf


Anders Lindgren schrieb:

>"Rolf F." <rolf.freitag@rolf...>
writes:
>
>  
>
>>Hi
>>
>>    
>>
>>>#ifdef __IAR_SYSTEMS_ICC__
>>>/* This is an IAR Compiler. */
>>>
>>>
>>>      
>>>
>>This works.
>>
>>    
>>
>>>#  if (((__TID__ >> 8) & 0x7f) == 43)
>>>/* This is the IAR MSP430 compiler. */
>>>
>>>#    if __VER__ < 200
>>>      
>>>
>
>How does it fail?
>
>Try to compile the following variant -- I've added #error:s to it so
>that it will report the result little bit more clearly.  I've also
>added one case at the bottom, if it triggers then you can try to
>change the initial #ifdef to "#if defined(__IAR_SYSTEMS_ICC__) ||
>defined(__IAR_SYSTEMS_ICC)", but hopefully this will not be necessary.
>
>When I apply this to our old compiler it reports:
>
>#      error "V1.xx of the compiler."
>-^
>"def.c",9  Error[141]: #error '"V1.xx of the
compiler."'
>
>Please let me know what happends when you compile the file.
>
>    -- Anders
>
>----------------------------------
>
>#ifdef __IAR_SYSTEMS_ICC__
>/* This is an IAR Compiler. */
>
>#  if (((__TID__ >> 8) & 0x7f) == 43)
>/* MSP430 */
>
>#    if __VER__ < 200
>
>#      error "V1.xx of the compiler."
>
>#    else
>
>#      error "V2.xx, or newer, of the compiler."
>
>#    endif
>
>#  elif (((__TID__ >> 8) & 0x7f) == 41)
>
>#    error "cr16"
>
>#  elif (((__TID__ >> 8) & 0x7f) == 45)
>
>#    error "cr16c"
>
>#  else
>
>#    error "unknown IAR compiler"
>
>#  endif
>
>#endif
>
>
>#if defined(__IAR_SYSTEMS_ICC) && !defined(__IAR_SYSTEMS_ICC__)
>#error "Only old symbol defined"
>#endif
>  
>