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

Reply via email to