We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all,
I have a small issue with a definition with arm C compiler regarding constants. In an assembly code I define a constant with :
Version EQU 0x01000100
In my main C file I import this const by :
extern unsigned int const Version;
Now my problem is to put this const in another const based on a struct :
const myType titi = { ..., // blabla Version, ... // blabla };
The compiler gives an error : Main.c(60): error: #28: expression must have a constant value But it's a constant !!!
Since my goal is to avoid multiple definition of same constant in severaal files, I'm looking for a solution to solve this problem.
Thanks by advance !
Thanks Mike,
Useful link that answers precisely to my question.
But for your information, the declaration of the constant in .s with equ keyword and the importation in c code works well. I use this for may years now.
Thanks again and best regards.
Now I'm curious. What tool is it that allows an EQU (a text macro in the scope of the assembler) to be accessible as a named symbol to the linker?
Don't know about ARM, but the original Intel '51 assembler definitely used to support it.
On the other hand, the c51 tools are very strange since the linker isn't just a linker but performs some of the code generation.
I simply use Keil uVision 4.54. Notice that I export the assembly constant by EXPORT keyword. That's it.
Best regards.
What tool is it that allows an EQU (a text macro in the scope of the assembler) to be accessible as a named symbol to the linker?
Those where EQU is actually not a text macro. The tell-tale signs that this is the case for a given assembler are:
* you can publish an EQU (PUBLIC, EXPORT, ...) * redefinining EQUs is forbidden * there are special rules for the value of an EQU (numeric, constant) * there is another facility for actual text replacement macros