This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: why the difference of two global pointers is not a constant?
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Rafael Espíndola <rafael dot espindola at gmail dot com>
- Cc: "GCC Mailing List" <gcc at gcc dot gnu dot org>
- Date: 25 Jul 2006 01:02:32 +0200
- Subject: Re: why the difference of two global pointers is not a constant?
- References: <564d96fb0607241330l6403bdf5h9bcd64630ab6a5fe@mail.gmail.com>
"Rafael Espíndola" <rafael.espindola@gmail.com> writes:
| 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).
because that is what the language standard says.
In general, the difference between two global pointers is something
known only to the linker -- too late to evaluate as constant
expression.
-- Gaby