Plot details - barchart reports

Derek Atkins warlord at MIT.EDU
Tue Feb 12 12:58:49 EST 2008


Hi,

"Davide Imbeni" <davide.imbeni at gmail.com> writes:

> Interesting.
>
> I actually got the warnings, but I'm forced to run configure with the
> flag --disable-error-on-warning, so I could compile even though.
>
> But your point makes me wonder about one thing:
>
> As I understand, you get errors with the statement:
>
>     GogObject *object = gog_object_get_child_by_role (...);
>
> but not when you correct it as follows:
>
>    GogObject *object;
>    object = gog_object_get_child_by_role (...);

That's not the problem.  The problem is that you have to declare
all your variables at the top of the block of code.  I.e., you
CAN have:

   GogObject *object = gog_object_get_child_by_role(...);

Provided that it's at the top of the block.  E.g.:

  {
   GogObject *object = gog_object_get_child_by_role(...);

   ...
  }

Is fine.   BUT this is not:

  {
   printf("Hi There\n");
   GogObject *object = gog_object_get_child_by_role(...);
   ...
  }

And indeed, just declaring the variable isn't sufficient, either.
This code is ALSO bad:

  {
   printf("Hi There\n");
   GogObject *object;
   object = gog_object_get_child_by_role(...);
   ...
  }

But this is okay:

  {
   GogObject *object;
   printf("Hi There\n");
   object = gog_object_get_child_by_role(...);
   ...
  }

> Now my question is, why don't you get the same error in the (very
> similar) statement about rotate_row_labels that comes right before?
>
>   if (rotate_row_labels) {
>     GogObject *object = gog_object_get_child_by_role (
>       chart, gog_object_find_role_by_name (chart, "X-Axis"));
>     style = gog_styled_object_get_style (GOG_STYLED_OBJECT (object));
>     gog_style_set_text_angle (style, 90.0);
>   }
>
> It looks like the very same statement to me (I actually copied it
> without understanding too much... :-( )
> What am I missing?

In this latter case, the declaration is at the top of the code block.
So yes, this code is fine.

-derek
-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list