Re: cal: First day of the week

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

 



Karel Zak, le Tue 10 Mar 2009 13:56:25 +0100, a écrit :
> On Tue, Mar 10, 2009 at 01:15:14PM +0100, Samuel Thibault wrote:
> > Karel Zak, le Tue 10 Mar 2009 13:09:22 +0100, a écrit :
> > >  You need to use union:
> > > 
> > > 		int wfd;
> > > 		union { unsigned int word; char *string; } val;
> > > 		val.string = nl_langinfo(_NL_TIME_WEEK_1STDAY);
> > > 
> > > 		wfd = val.word;
> > 
> > That will only work with the gcc compiler, which allows to read a union
> > field what you wrote in another.
> 
>  Hmm...
> 
>  C99, 6.5.2.3 Structure and union members
> 
>  82) If the member used to access the contents of a union object is
>      not the same as the member last used to store a value in the object,
>      the appropriate part of the object representation of the value is
>      reinterpreted as an object representation in the new type as
>      described in 6.2.6 (a process sometimes called "type punning"). This
>      might be a trap representation.

Uh, is that new in C99?  I thought it was a well-know gcc-only
extension, or maybe it's something else that is.

Samuel
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux