LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-02-2005, 02:38 AM   #1
ams
LQ Newbie
 
Registered: Feb 2005
Posts: 12

Rep: Reputation: 0
"dereferencing pointer to incomplete type"....what is the meaning of this?anybody?


i'm compiling these source code....and its appear liked below....

(the code)

/*
* Format the data and write it out to the output file
*/
tm_ptr = localtime( (time_t *)&data.time_tag.tv_sec );
switch( data.data_type )
{
case INTEGER_TYPE:
(163) fprintf(out_file,"%02d:%02d:%02d.%06d -- %d -- %d\n", tm_ptr->tm_hour, tm_ptr->tm_min,tm_ptr->tm_sec, data.time_tag.tv_usec, data.seq_num, data.raw_data.int_value);
break;
case FLOAT_TYPE:
(166) fprintf(out_file,"%02d:%02d:%02d.%06d -- %d -- %f\n", tm_ptr->tm_hour, tm_ptr->tm_min,tm_ptr->tm_sec, data.time_tag.tv_usec, data.seq_num, data.raw_data.float_value);
break;
default:
fprintf(stderr,"Recevied invalid packet type!\n");
}


(the error)

ams@lan ex7]$ gcc -c dataSink.c
dataSink.c: In function `main':
dataSink.c:159: warning: assignment makes pointer from integer without a cast
dataSink.c:163: dereferencing pointer to incomplete type
dataSink.c:163: dereferencing pointer to incomplete type
dataSink.c:163: dereferencing pointer to incomplete type
dataSink.c:166: dereferencing pointer to incomplete type
dataSink.c:166: dereferencing pointer to incomplete type
dataSink.c:166: dereferencing pointer to incomplete type

can anyone help me?

Last edited by ams; 03-02-2005 at 06:25 AM.
 
Old 03-02-2005, 07:28 AM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
It looks that line 159 is the localtime call. Are you sure tmp_ptr is really struct tm * ? There's problem with this or data is not what it should. Check also headers to see if you include all that's needed.
 
Old 03-02-2005, 09:08 AM   #3
ams
LQ Newbie
 
Registered: Feb 2005
Posts: 12

Original Poster
Rep: Reputation: 0
here is the full code of dataSink...

#include <sys/time.h> /* gettimeofday() */
#include <sys/types.h> /* miscelaneous calls */
#include <sys/stat.h> /* I/O, open()/close() */
#include <unistd.h> /* gettimeofday() and others */
#include <fcntl.h> /* I/O, open()/close() */
#include <stdio.h> /* Standard I/O, fprintf() */
#include <errno.h> /* perror() */
#include <termios.h> /* terminal functions */
#include <signal.h> /* signal functions */


/*
* Local header files
*/
#include "serialLib.h"
#include "dataFormat.h"

/*
* This is the input device, it is machine dependent and probably will need
* to be changed depending upon what machine you are on.
*
* Linux: /dev/ttyS1
* AIX: /dev/
* SunOS: /dev/
* Lynx: /dev/
*/
#define INPUT_DEVICE "/dev/ttyS1"


/*
* The main program
*/
int main( int argc, char *argv[] )
{

/*
* The time structures
*/
struct timeval start_time;
struct timeval end_time;

/*
* The data packet buffer and data
*/
data_t data;
char *buffer = (char *)&data;

/*
* The file pointer were the data will be written to
*/
FILE *out_file;

/*
* Miscellaneous variables
*/
int fp;
int i = 0;
int size;
struct tm *tm_ptr;
int bytes;
int total_bytes = 0;


/*
* Open the serial port using the serialLib calls. Note that for the
* reader, blocking I/O is used.
*/
if( (fp = serialOpen(INPUT_DEVICE, O_RDONLY)) == -1 )
{
exit(1);
}


/*
* Open the output file were the results will be written to
*/
if( (out_file = fopen( "out.file", "w" )) == (FILE *)NULL )
{
fprintf(stderr,"Could not open output file!\n");
serialClose(fp);
exit(1);
}


/*
* Get the start time of the processing
*/
gettimeofday(&start_time,NULL);


/*
* Loop for the number of packets expected
*/
while( i < NUM_OF_PACKETS )
{

/*
* The following sequence of code will read exactly one data packet
* from the serial port. Since the read statement will not always
* return the exact size of the packet, additional steps must be taken
* to be sure that a complete packet is read.
*
* First, the number of bytes read is initialized to zero. As long
* as the number of bytes read is less than the size of the data
* structure, a read will be performed. The number of bytes to read
* is simple the number of bytes read thus far (bytes) subtracted from
* the number of bytes in a packet (sizeof(data_t)). Each time a read
* is completed, the number of bytes read (size) is added to the bytes
* read (bytes). This continues until the packet is read from the
* serial port.
*/
bytes = 0;
while( bytes < sizeof(data_t) )
{
if( (size = read( fp, buffer + bytes, sizeof(data_t) - bytes)) == -1 )
{
perror("read failed");
serialClose(fp);
exit(1);
}
bytes += size;
}
total_bytes += bytes;


/*
* Verify that the sequence number in the packet matches the sequence
* number that is expected.
*/
if( data.seq_num != i )
{
fprintf(stderr,"Sequence number mismatch, current: %d -- recevied: %d\n", data.seq_num, i );
fprintf(stderr,"Adjusting sequence number to recieved value!\n");
i = data.seq_num;
}


/*
* Format the data and write it out to the output file
*/
tm_ptr = localtime( (time_t *)&data.time_tag.tv_sec );
switch( data.data_type )
{
case INTEGER_TYPE:
fprintf(out_file,"%02d:%02d:%02d.%06d -- %d -- %d\n", tm_ptr->tm_hour, tm_ptr->tm_min,
tm_ptr->tm_sec, data.time_tag.tv_usec, data.seq_num, data.raw_data.int_value);
break;
case FLOAT_TYPE:
fprintf(out_file,"%02d:%02d:%02d.%06d -- %d -- %f\n", tm_ptr->tm_hour, tm_ptr->tm_min,
tm_ptr->tm_sec, data.time_tag.tv_usec, data.seq_num, data.raw_data.float_value);
break;
default:
fprintf(stderr,"Recevied invalid packet type!\n");
}


/*
* Increment the number of packets received and complete the loop
*/
i++;
}


/*
* Get the ending time
*/
gettimeofday(&end_time,NULL);


/*
* Close the serial port
*/
serialClose(fp);


/*
* Close the output file
*/
fclose(out_file);


/*
* Calculate some statistics based on the data collected
*/
printf("----- Reciever -----\n");
printf("Total Packets: %d\n", i );
printf("Total Bytes Received: %d\n", bytes );
printf("Interval: %0.6f\n",
((float)(end_time.tv_sec - start_time.tv_sec) +
((float)(end_time.tv_usec - start_time.tv_usec)/1000000)));
printf("Data Rate: %0.6f\n",
((float)(i * sizeof(data_t))) /
((float)(end_time.tv_sec - start_time.tv_sec) +
((float)(end_time.tv_usec - start_time.tv_usec)/1000000)));

exit(0);
}
 
Old 03-02-2005, 09:11 AM   #4
ams
LQ Newbie
 
Registered: Feb 2005
Posts: 12

Original Poster
Rep: Reputation: 0
to run this thing...will only needs...these files...:

dataSource.c, dataSink.c, serialLib.c, serialLib.h, dataFormat.h

hope that this will help a little...
 
Old 03-02-2005, 10:13 AM   #5
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Please use code tags when posting code. It's so hard to read it otherwise...
 
Old 03-03-2005, 10:32 AM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Add #include <time.h>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tai64nlocal.c:55: error: dereferencing pointer to incomplete type ExCIA Linux - General 1 03-31-2009 09:49 AM
redeferenced pointer to incomplete type Aldair1808 Programming 1 11-28-2005 03:23 PM
arrays of elements with [gcc4]array type has incomplete element type lmmix Linux - Software 0 02-26-2005 08:07 AM
Incomplete type ChemicalBurn Programming 4 02-24-2005 08:44 AM
C error "dereferencing pointer to incomplete type" lucs Slackware 6 02-21-2005 09:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration