Re: What does ((time_t)-1) mean?



Kenneth Brody <kenbrody@xxxxxxxxxxx> writes:

Kenny McCormack wrote:

In article <1193218158.633181.69180@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
loudking <loudking@xxxxxxxxx> wrote:
Hello, all

I don't quite understand what does ((time_t)-1) mean when I execute
"man 2 time"


This (perfectly legal) program says that the answer to your question is 5:

#include <stdio.h>
int main(void)
{
int time_t = 6;
printf("The result is %d\n",((time_t)-1));
return 0;
}

Is it legal to declare a variable named "time_t"? True, you have
not included <time.h> which is why it "works".

Are you allowed to repurpose a type/variable/macro defined by the
standard, as long as you don't use anything related to the way
the standard defines them?

If, for example, defining your own printf() function invokes UB,
even if you never make reference (direct or otherwise) to the
standard's printf() function, doesn't the same hold true for the
time_t typedef?

If you don't include the definition then why isn't it perfectly ok?
Stupid, but ok.


.



Relevant Pages

  • Re: What does ((time_t)-1) mean?
    ... standard, as long as you don't use anything related to the way ... If, for example, defining your own printf() function invokes UB, ...
    (comp.lang.c)
  • Re: What does ((time_t)-1) mean?
    ... int main ... standard, as long as you don't use anything related to the way ... If, for example, defining your own printf() function invokes UB, ...
    (comp.lang.c)
  • Re: Optimising while(1);
    ... Where does any concrete requirement of the standard depend on what you ... The standard tells us, in detail, what the abstract machine must do. ... your printf calls do not necessarily ... printf, fflush(stdio); ...
    (comp.std.c)
  • Re: ES format
    ... >> runtime format, even a runtime format that is trivially constant, not. ... You aren't allowed by Standard C to define any _external_ linkage ... In particular you certainly can define a 'static' function printf(), ... but otherwise it is part of the language and the compiler ...
    (comp.lang.fortran)
  • Re: to stdio or not to stdio
    ... >> standard C library but your programs will. ... > I see that now - they have their own definitions of sprintf, ... function declaration with empty parentheses is _older_ and is the one ... The more recent 1999 version of the standard, called C99, does require ...
    (comp.lang.c)