[OT] C pointers: BSD versus Linux?

Matthew Dillon dillon at apollo.backplane.com
Wed May 31 13:24:27 PDT 2006


: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 at xxxxxxxxxxxxx>





More information about the Users mailing list