ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/04/06/09:01:04

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Message-ID: <20020406135915.23603.qmail@web10701.mail.yahoo.com>
Date: Sat, 6 Apr 2002 05:59:15 -0800 (PST)
From: Martin Sylvain <pype_1999 DOT geo AT yahoo DOT com>
Subject: BUG: mixing C constructors and field index fools gcc 2.9.5.2
To: djgpp AT delorie DOT com
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

I have a structure that is declared something like this:

struct kSemaphore {
    struct kMutex lock;
    int count;
    kThread* waiters;
};

and i want to be able to initialize it using the C structure constructor
feature:
mySem=(struct kSemaphore){ ... }

As stated in the GCC extensions, i expect this operation to wipe the memory
used by mySem before starting to do specific initialisation, so if i don't put
anything between the brackets, mySem should be all zeroes, right ?

As i'm a lazy coder, i do not feel the need to declare the content of the
'lock' component and only want to give a value to 'count', other fields can
remain zeroes, that's ok for me, so i write

mySem=(struct kSemaphore){count:1};

With gcc 2.7.2.1, this was working pretty well, but gcc 2.9.5.2 seems to
"forget" to write the 1, and i just get a all-zeroes structure once again !?

Note that i can get things working again by filling the whole structure, but i
don't see any reason why i *have* to do so ...

As i have wi(l)dely used that gcc feature in my code (clicker.sourceforge.net),
i would greatly appreciate if i hadn't to change it everywhere ...

Thanks in advance.


Pype (Sylvain Martin)
Happy DjGpp user since 1997

--
May the Source be with You 

__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019