Newbie question on time()

M

Mike Wahler

Dan Pop said:
In <[email protected]> "Mike Wahler"
^^^^^^^^^^^^^^^^^^
That's a bold statement for code invoking undefined behaviour:

Yes, I "misspoke".
fangorn:~/tmp 427> cat test.c
#include <stdlib.h>

int main()
{
srand(time());
return 0;
}
fangorn:~/tmp 428> gcc -ansi -pedantic test.c
fangorn:~/tmp 429>

So, let's rephrase: "if the code includes <time.h>, the call you show
above should not compile without a diagnostic".

Yes, thanks.
If the author was sloppy enough to call srand(time()), it is a safe bet
that he was sloppy enough not to include <time.h>.

And I was sloppy with my reply. It's a safe bet that
someone will point it out when I am. :)

-Mike
 
K

Keith Thompson

I see nothing in the wording above that prevents an implementation
from having exit statuses include EXIT_SUCCESS_WITH_PROMOTION_AND_RAISE
(equal to EXIT_SUCCESS) and
EXIT_SUCCESS_AND_YOU_KEEP_YOUR_JOB_FOR_ANOTHER_WEEK (equal to zero).
(no, I didn't say these were defined in <stdlib.h>). It doesn't
say the two implementation-defined forms have to be the same.

Except that EXIT_SUCCESS_WITH_PROMOTION_AND_RAISE and
EXIT_SUCCESS_AND_YOU_KEEP_YOUR_JOB_FOR_ANOTHER_WEEK are reserved for
use in <errno.h>.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top