This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]