Re: type-punning warnings with optimizations turned on?



On Fri, 2007-07-06 at 08:00 -0700, Alan M. Evans wrote:
On Fri, 2007-07-06 at 09:27 +0200, Jonathan Winterflood wrote:
Wouldn't that be
typedef struct MyMutex MyMutex;
rather?

Or for short :
typedex struct _MyMutex {
    GStaticMutex mutex;
} MyMutex;

Hi. Thanks for the input. But since this is C++, I'm not sure how that
makes a difference. Anyway, I tried it and the warnings remain.

That's right, your

    struct MyMutex {
        GStaticMutex mutex;
    };

is correct in C++.  You forgot to mention that you were using C++.  It
makes a difference here.

You say accessing GStaticMutex thingies elsewhere in your program
doesn't elicit these warnings?

Check to see if all the other places where you use it are places where
the thing being used is actually a pointer to a GStaticMutex.

I searched for GStaticMutex in /usr/include/glib2.0/*/*.h and found no
definition or declaration for it.  Therefore you can't hold one in your
program: they are opaque objects.  You must only hold pointers to them.

You can also initialize them statically via a macro.  This is the text
of a comment in gthread.h (the only .h file in the glib2.0 header tree):

/* GStaticMutexes can be statically initialized with the value
 * G_STATIC_MUTEX_INIT, and then they can directly be used, that is
 * much easier, than having to explicitly allocate the mutex before
 * use
 */


  // Wally

-- 
Wallace Owen L-3Com com
Office: 619.278.2084
Cell:   619.990.2286



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