global declarations

Ian Lance Taylor iant@google.com
Fri Sep 17 05:38:00 GMT 2010


Philip Herron <redbrain@gcc.gnu.org> writes:

> Been asking on irc tonight but i think many might be sensible and
> sleeping. Anyway's this has been bugging me for some time, if i create
> a VAR_DECL such as:
>
> tree test = build_decl( UNKNOWN_LOCATION, VAR_DECL,
> 			  get_identifier("test"),
> 			  integer_type_node);
>
>   TREE_CONSTANT (test) = 1;
>   DECL_ARTIFICIAL (test) = 1;
>   TREE_STATIC (test) = 1;
>   TREE_READONLY (test) = 1;
>   TREE_USED (test) = 1;
>   DECL_INITIAL (test) = build_int_cst(integer_type_node, 1234 );

By setting TREE_CONSTANT and TREE_STATIC, you are marking this decl as a
static const, more or less like a C++ const.  It will only be written
out if something else refers to it.  You probably don't want to set
TREE_CONSTANT.

Ian



More information about the Gcc-help mailing list