Global Variable

Asked by Sebastian Apelt

Hello,

I would like use a globale variable, that I define in the properties of the project or of eclipse.
I have see it is a build variable, but I can not use this build variable.
I have then set the build variable in the preprocessor defines as define.
Which define is then a octal number, because my build variable is "04.03.03.12".
How I can the build variable use as string or how I can define a globale variable with the string?

The compiler can only octal variables not strings. How I can get string variables with numerals into my code from the eclipse enviroment or build variables.

Thanks for the answere.

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Andreas Fritiofson (andreas-fritiofson) said :
#1

If I understand your question correctly, you should take a look at the Stringification section of the GCC manual:

https://gcc.gnu.org/onlinedocs/cpp/Stringification.html

Revision history for this message
Sebastian Apelt (s-apelt) said :
#2

No, I want get a String variable from eclipse eviroment into my code. With numbers it works with strings it doesn´t works.
"error: too many decimal points in number" answer gcc.

Revision history for this message
Sebastian Apelt (s-apelt) said :
#3

I have found a solution of my problem.

With the defines can the globale eclipse varaible import as a string variable.
The globale varaible is "VERSION_STRING" and is define as "04.03.03.22".

Solution:

#include <stdlib.h>

#define STRINGIZE(x) #x
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)

STRINGIZE_VALUE_OF(VERSION_STRING);

Can you help with this problem?

Provide an answer of your own, or ask Sebastian Apelt for more information if necessary.

To post a message you must log in.