diff options
author | schnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2005-09-26 00:21:00 +0000 |
---|---|---|
committer | schnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2005-09-26 00:21:00 +0000 |
commit | a1492b067055e73d5b61dfe45c3cd4200bee64a2 (patch) | |
tree | f0677049f29bd0d18f50337523989fc8a1c563ac /lib/sbin/create_c_stuff.pl | |
parent | 06d94fb1dae1bedc506b432ccb1157d6aaa874d8 (diff) |
Introduce macros CCTK_DECLARE and CCTK_DECLARE_INIT which declare or
declare and initialise local variables. They also add the necessary
magic to prevent compiler warnings about unused variables.
If the compiler supports __attribute__((unused)), then use this.
Otherwise, use the existing fallback of taking the variable's
address. In Fortran, use the variable's kind as fallback.
Use these macros in autogenerated code and in "cctk.h".
git-svn-id: http://svn.cactuscode.org/flesh/trunk@4146 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/create_c_stuff.pl')
-rw-r--r-- | lib/sbin/create_c_stuff.pl | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/sbin/create_c_stuff.pl b/lib/sbin/create_c_stuff.pl index 9c541bac..bbd1059e 100644 --- a/lib/sbin/create_c_stuff.pl +++ b/lib/sbin/create_c_stuff.pl @@ -176,7 +176,6 @@ sub CreateCStructureParameterHeader my(%parameters); my($type, $type_string); my(@definition); - my(@use); # Create the structure push(@data, '#ifdef __cplusplus'); @@ -187,7 +186,6 @@ sub CreateCStructureParameterHeader push(@data, 'extern struct'); push(@data, '{'); - push(@use, " const void *${structure}_use = ( \\"); foreach $parameter (&order_params($rhparameters, $rhparameter_db)) { my $type = $rhparameter_db->{"\U$rhparameters->{$parameter} $parameter\E type"}; @@ -207,11 +205,8 @@ sub CreateCStructureParameterHeader my $realname = $rhparameter_db->{"\U$rhparameters->{$parameter} $parameter\E realname"}; push(@data, " $type_string $realname$suffix;"); - push(@definition, " $type_string$varprefix const $parameter = $structure.$realname; \\"); - push(@use, " ${structure}_use = \&$parameter, \\"); + push(@definition, " CCTK_DECLARE_INIT ($type_string$varprefix const, $parameter, $structure.$realname); \\"); } - push(@use, " &${structure}_use \\"); - push(@use, ' );'); # Some compilers don't like an empty structure. if((keys %$rhparameters) == 0) @@ -229,7 +224,7 @@ sub CreateCStructureParameterHeader push(@data, "#define DECLARE_${structure}_PARAMS \\"); push(@data, @definition); - push(@data, @use); +## push(@data, @use); push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline @@ -244,7 +239,7 @@ sub order_params my(@int_params) = (); my(@string_params)= (); - foreach $parameter (sort(keys %$rhparameters)) + foreach $parameter (sort keys %$rhparameters) { $type = $rhparameter_db->{"\U$rhparameters->{$parameter} $parameter\E type"}; |