Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

#define compilation issue

Altera_Forum
Honored Contributor II
958 Views

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
0 Kudos
0 Replies
Reply