Working with frontend-specific aspects of GCC from a GCC plugin
Jakub Jelinek
jakub@redhat.com
Fri Dec 2 08:52:00 GMT 2011
On Wed, Nov 30, 2011 at 02:54:26PM -0700, Tom Tromey wrote:
> One idea that came up was to redeclare the FE-specific functions as
> 'weak', then check to see if they are available at runtime before
> calling them. It seems like a pain to me, since you have to rewrite the
> declarations, but I guess it could work. You could maybe write a plugin
> to write out the declarations :)
You don't need to rewrite them.
You can either use
extern __typeof (decl_as_string) decl_as_string __attribute__((weak));
(which has the downside that all references to decl_as_string from that CU
will be weak), or
static __typeof (decl_as_string) weak_decl_as_string __attribute__((weakref ("decl_as_string")));
where only the occurrences of weak_decl_as_string will be weak, if you
use decl_as_string in the CU somewhere, it will be strong.
But as others said, please look at langhooks first.
Jakub
More information about the Gcc
mailing list