FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 12-09-2008, 08:32 PM
Martin McCormick
 
Default Error Compiling C Code with Time and Date Functions.

I portedd some code I had written in FreeBSD unix over to
a new ubuntu-server system only to discover that none of the
time and date functions compile in Linux but do so under
FreeBSD. When referencing members of the structure timeptr such as

(timeptr->tm_year - 100), (timeptr->tm_mon) + 1, timeptr->tm_mday);

compilation finds an error every time. The following
fragment will produce the error:

struct tm *timeptr;
time_t elapsed_seconds; /*since midnight 1/1/70*/
time(&elapsed_seconds);
timeptr = localtime(&elapsed_seconds); /*fill structure*/
sprintf(newalarm,"alarms%02d%02d%02d", (timeptr->tm_year - 100), (timeptr->tm_mon) + 1, timeptr->tm_mday);

I actually ported over 8 small applications and all use
time and date and all fail to compile.

The error is:

"dereferencing pointer to incomplete type"

The headers I include are:

#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
#include <ctype.h>
#include <strings.h>
#include <sys/time.h>
#include <libgen.h>

Any ideas on the easiest way to satisfy gcc?

Thank you.

Martin McCormick

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-09-2008, 11:45 PM
"Steve Flynn"
 
Default Error Compiling C Code with Time and Date Functions.

On Tue, Dec 9, 2008 at 9:32 PM, Martin McCormick
<martin@dc.cis.okstate.edu> wrote:
> I portedd some code I had written in FreeBSD unix over to
> a new ubuntu-server system only to discover that none of the
> time and date functions compile in Linux but do so under
> FreeBSD. When referencing members of the structure timeptr such as
>
> (timeptr->tm_year - 100), (timeptr->tm_mon) + 1, timeptr->tm_mday);
>
> compilation finds an error every time. The following
> fragment will produce the error:
>
> "dereferencing pointer to incomplete type"
>

Without looking at your specifc issue (as you don't include the full
error messages and output), have you installed the 'build-essential'
package?

--
Steve
When one person suffers from a delusion it is insanity. When many
people suffer from a delusion it is called religion.

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-10-2008, 12:06 AM
Carl Flippin
 
Default Error Compiling C Code with Time and Date Functions.

On Tue, Dec 09, 2008 at 03:32:35PM -0600, Martin McCormick wrote:
> I portedd some code I had written in FreeBSD unix over to
> a new ubuntu-server system only to discover that none of the
> time and date functions compile in Linux but do so under
> FreeBSD. When referencing members of the structure timeptr such as
>
> (timeptr->tm_year - 100), (timeptr->tm_mon) + 1, timeptr->tm_mday);
>
> compilation finds an error every time. The following
> fragment will produce the error:
>
> struct tm *timeptr;
> time_t elapsed_seconds; /*since midnight 1/1/70*/
> time(&elapsed_seconds);
> timeptr = localtime(&elapsed_seconds); /*fill structure*/
> sprintf(newalarm,"alarms%02d%02d%02d", (timeptr->tm_year - 100), (timeptr->tm_mon) + 1, timeptr->tm_mday);

*snip*

> #include <sys/time.h>

Your problem seems to be here. On my machine at lease, time.h is not
in /usr/include/sys. It's in /usr/include. The struct you are making a
pointer to above is not defined in sys/time.h. You need:

#include <time.h>

I do see the struct defined there. It is a part of libc6-dev.

--
Carl Flippin | An idealist is one who, on noticing that a
carlf@photocarl.org | rose smells better than a cabbage, concludes
http://photocarl.org | that it will also make a better soup.
_____________________| -- H. L. Mencken
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 01:15 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org