Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

#define compilation issue

Hello,

I face a strange problem with gcc that I never faced with other compilers.

If for example, I have the following definitions :

In an include file :

# define BASE 0xF000# define REGISTER BASE + 0x02# define UBYTE unsigned char

In a code file :

*((UBYTE *)(REGISTER) = 0x00;

...

*((UBYTE *)(REGISTER) = 0xFF;

When i look at the assembler code, the address is calculated each time (0xF000 + 0x02) instead of being calculated at the compilation time.

Although both are literals ...

This involves additions, register transfers and is 2-3 times longer than what I can do by hand ..

This is very strange as both values are known at compilation time. Even if we use optimisation (-O2 or O3), it does nothing toward an optimisation which is not very difficult to carry out.

Did you faced such issues ?

Any idea or any optimisation flag to be used that you know about ?

With best regards,

Thierry
No RepliesBe the first to reply