Undefined reference to `gettimeofday'
Posted: Wed Jun 01, 2016 8:39 am
Hello masters,
This is my first time to use Netburner MOD5270.
Whenever I tried to compile the code, I get "undefined reference to 'gettimeofday'" message.
I think I spent enough time to figure out 'gettimeofday' problem. I seriously need a help!!
Here's my code:
If I remove the comment in extern "C" {...}, I get the following message:
..\main.cpp:10: error: declaration of C function 'int gettimeofday(timeval*, timezone*)' conflicts with
C:\nburn/gcc-m68k/m68k-elf/include/sys/time.h:73: error: previous declaration 'int gettimeofday(timeval*, void*)' here
I saw some related posts, but no one solved this matter.
Please help me out. Thanks!
This is my first time to use Netburner MOD5270.
Whenever I tried to compile the code, I get "undefined reference to 'gettimeofday'" message.
I think I spent enough time to figure out 'gettimeofday' problem. I seriously need a help!!
Here's my code:
Code: Select all
#include "predef.h"
#include <stdio.h>
#include <startnet.h>
#include <autoupdate.h>
#include <dhcpclient.h>
#include <sys/time.h>
extern "C" {
void UserMain(void * pd);
//int gettimeofday(struct timeval *t, struct timezone *tz);
}
void UserMain(void * pd)
{
InitializeStack();
if (EthernetIP == 0) GetDHCPAddress();
OSChangePrio(MAIN_PRIO);
EnableAutoUpdate();
timeval now;
while (1) {
gettimeofday(&now, 0);
iprintf("%ld.%06ld\n", now.tv_sec, now.tv_usec);
OSTimeDly(10);
}
}
If I remove the comment in extern "C" {...}, I get the following message:
..\main.cpp:10: error: declaration of C function 'int gettimeofday(timeval*, timezone*)' conflicts with
C:\nburn/gcc-m68k/m68k-elf/include/sys/time.h:73: error: previous declaration 'int gettimeofday(timeval*, void*)' here
I saw some related posts, but no one solved this matter.
Please help me out. Thanks!