473,395 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

struct tm

Under c90, not c99, where is the behavior
outlined for memset zeroing such an
object of this struct type? I know
under c99 you have the possibility
of creating a trap representation or
raising an implementation defined signal
but what about c90?

--
aegis

Jun 21 '07 #1
9 6511
aegis <ae***@mad.scientist.comwrote:
Under c90, not c99, where is the behavior
outlined for memset zeroing such an
object of this struct type? I know
under c99 you have the possibility
of creating a trap representation or
raising an implementation defined signal
but what about c90?
Note 122 (in the definition of memcmp()) refers to the memset()ing of
struct objects as if it were no problem, and I can find no reason to
suspect otherwise. Therefore, I assume that memset()ing the alignment
and padding bytes in a struct has no impact on the struct's validity
(after all, they are otherwise indeterminate anyway); and that doing so
to any declared struct members is as valid as if they had been normal
objects instead of struct members. So memset()ing unsigned chars struct
members is certainly valid, and memset()ing float struct members only
depending on the floating point model the implementation uses.

Richard
Jun 21 '07 #2
aegis said:
Under c90, not c99, where is the behavior
outlined for memset zeroing such an
object of this struct type?
Everything in it is an int, so you're in the clear. It isn't actually
possible AFAIK to prove from C90 that memsetting (to 0) an aggregate
object containing only integral types will give each of them the value
0, but IIRC according to ISO there are *no* implementations where it
doesn't. I'd give references if I had them. Perhaps someone from ISO
can clarify.
I know under c99 you have the possibility
of creating a trap representation or
raising an implementation defined signal
I don't think so, actually - not for 0.
but what about c90?
I consider myself a rather conservative C programmer, and I regularly
blast an entire memset's-worth of 0s right through my integer-only
aggregate data structures. Not terribly often, though - and, to be
precise, not all that regularly either. But sometimes, anyway. What
*is* the word? Ah! Fearlessly. I fearlessly use memset to 'zero out'
integer-only aggregate data structures. Despite the fact that I haven't
a clue what platforms my code will be run on.

Of course, if there are pointers or floaty-pointy thingies around,
that's a different matter.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 21 '07 #3
Richard Heathfield wrote On 06/21/07 06:43,:
aegis said:

>>Under c90, not c99, where is the behavior
outlined for memset zeroing such an
object of this struct type?


Everything in it is an int, so you're in the clear. [...]
Nitpick: Everything *required* to be in it is an int.
The Standard allows an implementation's struct tm to have
elements other than those listed, and the types of any
extra elements could be whatever the implementation liked.

Personally, I'd just initialize at declaration:

struct tm when = { 0 };

If you need to re-clear it after using it (why?), memset
is very likely safe. For freedom from all possible worry:

static const struct tm zero = { 0 };
struct tm when;
...
when = zero; /* instead of memset */
... fill it in and use it ...
when = zero;
... play it again, Sam ...

--
Er*********@sun.com
Jun 21 '07 #4
aegis wrote:
>
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99 you
have the possibility of creating a trap representation or raising
an implementation defined signal but what about c90?
Totally incomprehensible without proper quoting. What struct
type? What object? See the reference in my sig. below.

--
If you want to post a followup via groups.google.com, ensure
you quote enough for the article to make sense. Google is only
an interface to Usenet; it's not Usenet itself. Don't assume
your readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell.org/google/>

--
Posted via a free Usenet account from http://www.teranews.com

Jun 21 '07 #5
"CBFalconer" writes:
aegis wrote:
>>
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99 you
have the possibility of creating a trap representation or raising
an implementation defined signal but what about c90?

Totally incomprehensible without proper quoting. What struct
type? What object? See the reference in my sig. below.
I agree that the post could have used a few more words. But he used legal
buzzwords and I got at least some meaning out of it. See the link.

http://www.dinkum.com/manuals/?manua...page=time.html
Jun 21 '07 #6
CBFalconer said:
aegis wrote:
>>
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99 you
have the possibility of creating a trap representation or raising
an implementation defined signal but what about c90?

Totally incomprehensible without proper quoting.
Quoting of what, Chuck? He's the OP!

What is happening to you?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 21 '07 #7
Richard Heathfield wrote:
CBFalconer said:
>aegis wrote:
>>>
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99
you have the possibility of creating a trap representation or
raising an implementation defined signal but what about c90?

Totally incomprehensible without proper quoting.

Quoting of what, Chuck? He's the OP!

What is happening to you?
I virtually never look at the subject. I suspect he constructed a
new thread out of a reply to something else.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 22 '07 #8
CBFalconer <cb********@yahoo.comwrites:
Richard Heathfield wrote:
>CBFalconer said:
>>aegis wrote:
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99
you have the possibility of creating a trap representation or
raising an implementation defined signal but what about c90?

Totally incomprehensible without proper quoting.

Quoting of what, Chuck? He's the OP!

What is happening to you?

I virtually never look at the subject. I suspect he constructed a
new thread out of a reply to something else.
That doesn't appear to be the case. If there's insufficient context,
I suggest that you *should* look at the subject before jumping to
conclusions.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 22 '07 #9
Keith Thompson wrote, On 22/06/07 03:53:
CBFalconer <cb********@yahoo.comwrites:
>Richard Heathfield wrote:
>>CBFalconer said:
aegis wrote:
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99
you have the possibility of creating a trap representation or
raising an implementation defined signal but what about c90?
Totally incomprehensible without proper quoting.
Quoting of what, Chuck? He's the OP!

What is happening to you?
I virtually never look at the subject. I suspect he constructed a
new thread out of a reply to something else.

That doesn't appear to be the case.
I just checked and there were no references headers, so it definitely
was not the case.
If there's insufficient context,
I suggest that you *should* look at the subject before jumping to
conclusions.
Chuck, you should definitely check before claiming someone should quote
context. Complaining at the OP for not putting all of the information in
the message would be valid, but that is not the complaint made.
--
Flash Gordon
Jun 23 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Roy Hills | last post by:
When I'm reading from or writing to a network socket, I want to use a struct to represent the structured data, but must use an unsigned char buffer for the call to sendto() or recvfrom(). I have...
10
by: Rick Anderson | last post by:
All, I am receiving the following compilation error on LINUX (but not Solaris, HPUX, WIN32, etc): compiling osr.c LBFO.h(369): warning #64: declaration does not declare anything extern...
5
by: PCHOME | last post by:
Hello! I am working on dividing a single C file into several files. Now I encounter a problem about the global variables and can not find a way to solve it. All global variables and codes used...
19
by: Russell Shaw | last post by:
Hi, I have two structs in a header file, and they reference each other, causing a compile error. Is there a standard way to deal with this? typedef struct { ... RtAction *actions; }...
16
by: burn | last post by:
Hello, i am writing a program under linux in c and compile my code with make and gcc. Now i have 4 files: init.c/h and packets.c/h. Each header-file contains some: init.h: struct xyz {
5
by: Johs32 | last post by:
I have a struct "my_struct" and a function that as argument takes a pointer to this struct: struct my_struct{ struct my_struct *new; }; void my_func(struct my_struct *new); I have read...
7
by: Alex | last post by:
If I have two struct. See below: struct s1 { int type; int (*destroy)(struct s1* p); } struct s2 { struct s1 base;
4
by: hobbes992 | last post by:
Howdy folks, I've been working on a c project, compiling using gcc, and I've reached a problem. The assignment requires creation of a two-level directory file system. No files have to be added or...
4
by: hugo.arregui | last post by:
Hi! I have two struts like that: struct { int num; int num2; struct b arrayOfB; } a;
4
by: Sheldon | last post by:
Hi, I have a unique case where I need an array of structs that grows and within this array is another struct that grows in some cases. I'm having trouble allocating memory. Since I have never...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.