How to temporarily disable the -Ansi option

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to temporarily disable the -Ansi option

ソリューションへジャンプ
2,270件の閲覧回数
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

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,574件の閲覧回数
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 件の賞賛
返信
3 返答(返信)
1,574件の閲覧回数
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 件の賞賛
返信
1,574件の閲覧回数
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,575件の閲覧回数
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 件の賞賛
返信