[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Hvad skal jeg linke?



Anders Melchiorsen wrote:

> > av2.c: In function `main':
> > av2.c:14: `timeval' undeclared (first use in this function)
> > av2.c:14: (Each undeclared identifier is reported only once
> > av2.c:14: for each function it appears in.)
>
> Jeg tror, du skal skrive "struct timeval" i stedet for "timeval" i
> linie 14.

Jeg prøvede men det virkede desværre ikke. Jeg må hellere vise lidt
kode:

#include<stdio.h>
#include<sys/time.h>
#include<unistd.h>
#include<stdlib.h>
// ....
  timeval* t1; //linje 14
  timeval* t2;
  t1 = (timeval*)malloc(sizeof(timeval));
  t2 = (timeval*)malloc(sizeof(timeval));
  gettimeofday(t1,NULL);
// ting der tager tid
  gettimeofday(t2,NULL);
  long secs = t2->tv_usec - t1->tv_usec < 0 ? t2->tv_sec - t1->tv_sec -
1 : t2->tv_sec - t1->tv_sec;
  long usecs = (t2->tv_usec - t1->tv_usec < 0 ? 1000000 : 0) +
t2->tv_usec - t1->tv_usec;
  printf("Tid: %i sekunder og %i mikrosekunder\n",secs, usecs);
  free(t1);
  free(t2);
// .....

Prøver jeg som Anders foreslår at tilføje struct i linje 14 og 15,
brokker den sig i linje 16 med samme fejl, og der hjælper det ikke at
tilføje struct.
Laver jeg en ldd på mit C++ program ser jeg det linker libm, men det
hjælper ikke at tilføje -lm når jeg kompilerer.
Jeg er lidt på bar bund her :(
Håber nogen kan hjælpe, ellers må jeg jo bare lave det som C++.

VH
Christian Hemmingsen



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *