[Techtalk] getting the time as a string in c

Laurel Fan laurel.fan at gmail.com
Thu Sep 29 07:18:27 EST 2005


On 9/28/05, kristina clair <kclair at gmail.com> wrote:
>     size_t strftime(timestring, timestrsize, timeformat, timeptr);
>
>
> gcc is complaining:
> program.c: In function `main':
> program.c:38: warning: parameter names (without types) in function declaration

I won't repeat the other great responses about how to actually do what
you want, but I'll try to explain this warning.

So it looks like you copied that line from the strftime man page, which is:

       size_t strftime(char *s, size_t max, const char *format,
                           const struct tm *tm);

This is a function declaration (like sub ... in perl).  If you want to
call the function, you would do:

      strftime(timestring, timestrsize, timeformat, timeptr);

without the size_t.  A C function declaration generally looks like:

<return type> <function name>(<list of arguments with type>)

while a function call looks like:

<function name>(<list of arguments without type>)

Of course in Perl you don't use types, or named arguments, so a
declaration in perl doesn't include the return type or argument list.

Incidentally, since this was a warning, this line isn't actually what
caused it to not compile; but I'm sure you got an error a few lines
later because it was expecting the rest of the function declaration...

--
Laurel Fan
http://dreadnought.gorgorg.org


More information about the Techtalk mailing list