Can I get the address of an object as a string constant in g++? Example:
struct s { } x;
If &x == 1234, then I need "1234" in my code.
EDIT:
By string constant I meant that I need that constant string at compile- or link-time. I need to embed it in inline assembly code like this:
template < typename U >
struct T {
static int x;
void f () {
asm (".word " some-expression-containing-(&x));
}
};
I don’t know a way to construct the mangled name with a preprocessor macro, so I asked this question.
The solution doesn’t need to be portable, g++ is sufficient.
The address itself is known at compile- or link-time though, as it would work to examine the assembly output and put in the mangled name into the inline assembly instruction.
This works for me in g++.