|
|
View previous topic :: View next topic |
Author |
Message |
hunterc
Joined: 29 Nov 2004 Posts: 2
|
Function definition different from previous definition |
Posted: Sun Feb 20, 2005 10:14 pm |
|
|
I'm getting a "Function definition different from previous definition" error from the following code.
First is a snippet from Argos.h which is included before Argos.c in the main program file. The problem is with the ArgosBuildMessage function near the end. I've added '..\common' to the include path in case you are wondering about the syntax in the #includes.
If I remove the last parameter from the prototype and definition it compiles fine. Is this a precedence issue with the pointer to a two dimensional array?
Any suggestions most welcome
*****FROM ARGOS.H************************
#define MESSAGE_LENGTH 10
CHAR ArgosMessageLength = MESSAGE_LENGTH; // maximum of 31 data bytes plus the 7 header and ID bytes
CHAR ArgosMessage [MESSAGE_LENGTH] =
{HEADER0, HEADER1, HEADER2, ID0, ID1, ID2, ID3, 0, 0, 0};
#define MSG_TYPE 1
#define MSG_HOUR 2
#define MSG_MIN 3
#define MSG_DLAT 4
#define MSG_DLON 5
#define MSG_HDOP 6
#define MSG_SATS 7
#define MSG_LAT 8
#define MSG_LON 9
#define MSG_CSUM 10
#define ELEMENTS 10
CHAR msg_format[2][ELEMENTS] =
{
{
MSG_TYPE, MSG_HOUR, MSG_MIN, MSG_DLAT, MSG_DLON, MSG_HDOP, MSG_SATS, MSG_LAT, MSG_LON, MSG_CSUM
},{
2, 5, 6, 10, 10, 4, 4, 15, 16, 8
}
};
void ArgosBuildMessage (time *gpstp, gprmc *rp, CHAR message_length, CHAR *message [MESSAGE_LENGTH], CHAR *msg_format[2][ELEMENTS]);
void ArgosTransmit (CHAR message_length, CHAR *message [MESSAGE_LENGTH]);
*****END OF ARGOS.H SNIPPET***********
The second snippet is from Argos.c
*****FROM ARGOS.C********************
void ArgosBuildMessage (time *gpstp, gprmc *rp, CHAR message_length, CHAR *message [MESSAGE_LENGTH], CHAR *msg_format[2][ELEMENTS])
{
CHAR bit_count, bits, byte_count, data_byte, temp, i, j;
unsigned int16 data_word;
*****END OF ARGOS.C SNIPPET***********
the #includes from the main program are as follows
*****FROM MAIN PROG******************
#include <Common.h>
#include "GPSArgosLogger.h"
#include <stdlib.h>
#include <string.h>
#include <GPS.h>
#include <RealTimeClock.h>
#include "StartUp.h"
#include "Argos.h"
#include "..\common\gps.c"
#include "..\common\RealTimeClock.c"
#include "interrupts.c"
#include "Argos.c"
***** END OF MAIN PROG SNIPPET****** |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 20, 2005 11:45 pm |
|
|
I was able to duplicate the problem with PCM vs. 3.219.
One possible work-around would be just treat the pointers
as 16-bit numbers. Then create two-dimensionals arrays
of int16 values. I made a program to test this and it works.
The output of the program is: ptr = 0190, *ptr = 55
Unless someone else has a better solution, I guess your
alternative is to report it to CCS and wait for an update.
Code: | #include <16F877.H>
#device *=16
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
// Function prototype.
void ABM(int16 msg_format[2][3]);
// Create an array of numbers, and assign it to a memory
// location such that it requires a 16-bit pointer.
char array[10] = {0x55,1,2,3,4,5,6,7,8,9};
#locate array = 0x190
//===================================
void main()
{
int16 msg_ptr_array[2][3];
// Put the address of the char array into the
// two-dimensional array, at a location roughly
// in the middle of the array, just to make sure
// that it works anywhere, and not just at [0][0].
msg_ptr_array[1][2] = array;
ABM(msg_ptr_array);
while(1);
}
//================================
void ABM(int16 msg_format[2][3])
{
char *ptr;
ptr = msg_format[1][2];
// Display the value of the pointer and the
// char that it points to.
printf("ptr = %lx, *ptr = %x ", ptr, *ptr);
} |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|