DragonFly BSD
DragonFly users List (threaded) for 2006-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: [OT] C pointers: BSD versus Linux?


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 May 2006 13:22:15 -0700 (PDT)

:Hi compiler/OS gurus,
:
:Please consider this trivial fragment of c code which I've
:written in two different styles:
:
:Style 1:
:time_t t*;
:time(t);
:
:Style 2:
:time_t t;
:time(&t);
:
:My puzzle is this:  on *BSD these two different styles work
:identically -- but on my linux boxes Style 1 produces a
:run-time error, while Style 2 works as expected.
:
:Anyone here know why this difference?
:
:Thanks for any clues!

    Well, the first bit of code is illegal. The 't' pointer has to point
    to something.  e.g.:

    time_t blah;
    time_t *t = &blah;

    time(t);

    With that fixed, both styles work fine under either Linux or BSD.  You
    do have to #include <time.h>, of course.

					-Matt
					Matthew Dillon 
					<dillon@xxxxxxxxxxxxx>



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