diff options
author | swhite <swhite@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2006-10-26 12:17:42 +0000 |
---|---|---|
committer | swhite <swhite@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2006-10-26 12:17:42 +0000 |
commit | 81e9c2449fbcae17658163af750382744cfee06c (patch) | |
tree | 9db1b0a2effbea12ec1042d6bd29c63b9bf40ca9 /lib/sbin/create_c_stuff.pl | |
parent | 0d8e0648fd8ea848f2bf1a6199251cda266af84b (diff) |
This is the application of the patch reported in Patches and Developsrs
Fri 20 Oct 06
"g++ warning: operation on *bla* may be undefined"
and PR 2070
http://www.cactuscode.org/cactus_cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&data
base=cactus&pr=2070
Preprocessing arrangements/Carpet/Carpet/src/Timing.cc
Compiling arrangements/Carpet/Carpet/src/Timing.cc
configs/chain_gcc_carpet/build/Carpet/Timing.cc:
In function ‘void Carpet::InitTimingVariables(const cGH*)’:
configs/chain_gcc_carpet/build/Carpet/Timing.cc:120:
warning: operation on ‘cctki_use’ may be undefined
The culprit was in generated bindings code meant to get rid of warnings
about unused variables corresponding to Cactus parameters included in
code by the DECLARE_CCTK_PARAMETERS macro.
This replaces the offending code with enums initialised by sizeof calls;
the nature of all the entities involved is much clearer, both to
compilers and to me.
Like the existing solution, this permits the user to proceed to make more
declarations after the DECLARE_CCTK_PARAMETERS macro (simply putting a list
of variable assignments after the declaration would not have that property).
git-svn-id: http://svn.cactuscode.org/flesh/trunk@4381 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/create_c_stuff.pl')
-rw-r--r-- | lib/sbin/create_c_stuff.pl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/sbin/create_c_stuff.pl b/lib/sbin/create_c_stuff.pl index 9c541bac..124fd560 100644 --- a/lib/sbin/create_c_stuff.pl +++ b/lib/sbin/create_c_stuff.pl @@ -186,8 +186,8 @@ sub CreateCStructureParameterHeader push(@data, ''); push(@data, 'extern struct'); push(@data, '{'); + my $delim = ' '; - push(@use, " const void *${structure}_use = ( \\"); foreach $parameter (&order_params($rhparameters, $rhparameter_db)) { my $type = $rhparameter_db->{"\U$rhparameters->{$parameter} $parameter\E type"}; @@ -208,10 +208,9 @@ sub CreateCStructureParameterHeader push(@data, " $type_string $realname$suffix;"); push(@definition, " $type_string$varprefix const $parameter = $structure.$realname; \\"); - push(@use, " ${structure}_use = \&$parameter, \\"); + push(@use, " $delim dummy\_$structure\_$parameter = sizeof( $parameter ) \\"); + $delim = ','; } - push(@use, " &${structure}_use \\"); - push(@use, ' );'); # Some compilers don't like an empty structure. if((keys %$rhparameters) == 0) @@ -229,7 +228,12 @@ sub CreateCStructureParameterHeader push(@data, "#define DECLARE_${structure}_PARAMS \\"); push(@data, @definition); - push(@data, @use); + if( @use ) + { + push(@data, " enum { \\"); + push(@data, @use); + push(@data, " }; \\"); + } push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline |