From a1492b067055e73d5b61dfe45c3cd4200bee64a2 Mon Sep 17 00:00:00 2001 From: schnetter Date: Mon, 26 Sep 2005 00:21:00 +0000 Subject: 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 --- lib/sbin/create_c_stuff.pl | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'lib/sbin/create_c_stuff.pl') 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"}; -- cgit v1.2.3