Re: [gtk-list] Re: Passing a struct through a gtk_connect_signal



Bonjour Emmanuel :-) Hi ALL :-)

>     Why do you want to do that? Once you declare a type,
>     you can use everywhere (if it is defined in a header file
>     of course), so I don't see any kind of problem here.

That's right. The problem is that I'm 100% sure that I'll use this only in
this piece of code. Why then define a new type JUST for this (it just
seemed to me like using a cannon to kill a fly :-). If it would be another
way to do this, without ANY KIND of global definition/declaration, this
would represent an optimisation to the code... or not? 

>     You cannot define a 'static type'. You define a type or you define
>     a variable. If you define a var (with struct { } toto_var;) then
>     your struct is not usable anywhere in your program. You
>     should declare a type (typedef struct { } toto_type;) which will
>     let you define any var (with toto_type *toto_var; for example)
>     or cast any kind of data to you type 
>     (toto_var = (toto_type *)user_data; }

Ok.

>     When you declare a variable as global, you:
> 
>     * have some chance to polute the code of a third part library
>     (say, if you are defining a 'foo' var which is already defined
>     in another module, you've got chances to do Really Bad Things)
>     
>     * if your code piece is a library, you'll get a non reentrant 
>     library    
> 
>     That's actually why adding global var to your code is not a 
>     good idea (and there are other reasons).

Fine! Just another reason to avoid the use of any kind of global 
declarations/definitions at maximum. Thanks for the explication.

>     It seems that you are quite confused by C (I maybe wrong,
>     of course :).

It would be not the first time! :-) :-) :-)

>     Yours,
> 
>     Emmanuel
> 
> > Anyway, I'll implement the suggested solution. Thanks A LOT for the help! 

BTW, the thing works :-) Thanks a lot for the help!

Best regards,

Rafael (8-)

rafael@bmt4.kf.TU-Berlin.DE
Take a look at our site!
http://privat.schlund.de/bsos/
______________________________

"Unshakable faith is only that
 which can meet reason face to
 face in every Human epoch"

              Allan Kardec
              (1804-1869)
______________________________



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]