How to temporarily disable the -Ansi option

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to temporarily disable the -Ansi option

Jump to solution
2,272 Views
davide_ferrari
Contributor II

Hi

I'd like to use CodeWarrior for HCS12(X) Microcontrollers (S12XE processor) with the strict Ansi option enabled (-Ansi).

 

The library files are not compliant with this option (i.e. mc9s12xep100.h has the bitfields defined with byte type).

 

Is there a way to temporarily disable this option in a file?

 

I'd like to avoid to modify the library files to make them compliant....

 

Many thanks

Davide

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,576 Views
CrasyCat
Specialist III

Hello

 

-Ansi option can only be used on command line.

There is no way to activate/deactivate it through pragma.

 

CrasyCat

View solution in original post

0 Kudos
Reply
3 Replies
1,576 Views
davide_ferrari
Contributor II

Thank you.

 

So any idea on how to compile a project with -Ansi option enabled within CW (using the standard files and libraries)?

 

Davide

0 Kudos
Reply
1,576 Views
Lundin
Senior Contributor IV
There is no way to do that since Codewarrior is using non-standard bitfields for the register definitions, and also some nonsense operator "@" they invented themselves (needlessly). Why this weird syntax is used still, I have no idea. CW is otherwise good at fulfilling standard C with its neat #pragmas for ISRs, code allocation etc.

The only solution to this is to rewrite the register headers manually, using pre-processor #defines and bit masks. That is, using the following fully portable standard C:


#define SOME_REGISTER (*(volatile uint8_t*)0x1234)
#define SOME MASK 0x01


/* set bit to 1 */
SOME_REGISTER |= SOME_MASK;

/* set bit to 0 */
SOME_REGISTER &= ~SOME_MASK;


Still... nothing will save you from inline assembler. If you have that -Ansi option enabled you can't use inline assembler, which is quite troublesome :smileyhappy:
1,577 Views
CrasyCat
Specialist III

Hello

 

-Ansi option can only be used on command line.

There is no way to activate/deactivate it through pragma.

 

CrasyCat

0 Kudos
Reply