This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
why the difference of two global pointers is not a constant?
- From: "Rafael EspÃndola" <rafael dot espindola at gmail dot com>
- To: "GCC Mailing List" <gcc at gcc dot gnu dot org>
- Date: Mon, 24 Jul 2006 17:30:21 -0300
- Subject: why the difference of two global pointers is not a constant?
I am trying to build a table with offsets of global pointers from a
given pointer:
void *fs[] = {f1 - f1, f2 - f1};
where f1 and f2 are functions.
GCC is able to figure out that (f1 - f1) is 0, but says "initializer
element is not constant" when trying to compute (f2 - f1).
It is possible to solve the problem by declaring fs with an inline asm:
asm("fs:\n"
".quad f1 - f1\n"
".quad f2 - f1\n");
Is there a way to do it with C? It works in visual studio.
Sorry if this isn't the appropriate mailing list, but it looks like
this is an intentional design decision.
Thanks,
Rafael