470,850 Members | 1,371 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,850 developers. It's quick & easy.

Link-time error when used _strdate() and _strtime()


I am trying to compile the following program :

#include <stdio.h>
#include <time.h>

int main( )
char dateStr [9];
char timeStr [9];

_strdate( dateStr);
printf( "The current date is %s \n", dateStr);
_strtime( timeStr );
printf( "The current time is %s \n", timeStr);

and get the following compile/link time error message :

$ gcc date.c
/tmp/ccyJ9mFr.o: In function `main':
date.c:(.text+0x23): undefined reference to `_strdate'
date.c:(.text+0x41): undefined reference to `_strtime'
collect2: ld returned 1 exit status

It appeared that the program compiled OK. But the linker could not find
_strdate and _strtime.

Does anyone how to fix this problem?

Thank you for your help.

Apr 16 '08 #1
1 5060
671 Expert 512MB
Aside: please use CODE tags when posting code. We programmers need to see properly formatted code, so if you want the most help for your questions, do take the time to add those tags. It doesn't take long, but lots more people will help you out.

You may be surprised to learn that _strdate and _strtime are not part of standard C. They are Microsoft extensions to time.h, which do not exist in other compilers. Hence, gcc can't compile the code, because _strdate and _strtime do not exist.
Apr 16 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Eric W. Holzapfel | last post: by
1 post views Thread by Jean-Marc Molina | last post: by
7 posts views Thread by Shawn Windle | last post: by
8 posts views Thread by sudhirlko2001 | last post: by
1 post views Thread by sri2097 | last post: by
3 posts views Thread by nick | last post: by
7 posts views Thread by gehegeradeaus | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.