|
|
View previous topic :: View next topic |
Author |
Message |
syide
Joined: 10 Nov 2008 Posts: 16 Location: Malaysia
|
why this error happen? |
Posted: Wed Feb 18, 2009 1:06 pm |
|
|
Why this error happen??
main
Code: | #define STACK_USE_PPP 1
#define STACK_USE_MAC 0
#define STACK_USE_ICMP 1
#define STACK_USE_TCP 1
#include <18F4620.h>
#use delay(clock=4000000)
#fuses H4
#fuses NOFCMEN
#fuses NOXINST
#fuses NOIESO
#fuses NOPBADEN
#fuses MCLR
#fuses NOWDT
#fuses NOPROTECT
#fuses NODEBUG
#fuses NOSTVREN
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=user,errors)
#include "tcpip/stacktsk.c" //include Microchip's TCP/IP stack
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while(TRUE)
{
}
}
|
|
|
|
Ttelmah Guest
|
|
Posted: Thu Feb 19, 2009 3:14 am |
|
|
Unfortunately, we can't tell.
CCS, has a 'habit', of reporting errors, a long way after where the real error is. It tends, for certain types of function defintion errors, to 'plough on', and then report an error when a latter function is declared.
I'd guess the actual error, is probably in pppwrap.h, or in the declaration of the type 'PPP_BUFFER_CHOICE', since the actual error line, is the first function definition after the latter is used, and after the former is included.
Best Wishes |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Feb 19, 2009 3:38 am |
|
|
I think, the said behaviour is caused by operation method of the C preprocessor, which is simply including text. You may have e.g. unmatched parenthesis in an include file.
Generally, you should find a method to locate multi-file spanning syntax errors yourself. Reducing the code step-by-step until the error vanishes is my usual way. The feature of the CCS source editor to show matching parenthesis may be helpful as well. |
|
|
syide
Joined: 10 Nov 2008 Posts: 16 Location: Malaysia
|
|
Posted: Thu Feb 19, 2009 4:21 am |
|
|
This is PPPWRAP.H
Code: |
#ifndef __TCPIP_STACK_PPPWRAP_MODULE_H
#define __TCPIP_STACK_PPPWRAP_MODULE_H
#define MAC_IP 0
#define MAC_ARP 6 //wont be used, but keep it defined
#define INVALID_BUFFER 0xFF
typedef struct __PPP_TX_BUFFER {
//int1 txen;
int16 txpos; //when writing to buffer (storing), use this index
int16 rxpos; //when reading from buffer (transmitting), use this index
int16 txlen; //amount of bytes in this buffer
int8 data[MAC_TX_BUFFER_SIZE];
} PPP_TX_BUFFER;
//use modem.c's buffer routines for reading/writing to the buffer
typedef struct __PPP_RX_BUFFER {
int16 len; //length of IP packet. hopefully it doesn't go over MAC_RX_BUFFER_SIZE
int16 index;
} PPP_RX_BUFFER;
typedef enum __PPP_BUFFER_CHOICE {PPP_RX_ACTIVE, PPP_TX_ACTIVE} PPP_BUFFER_CHOICE;
///mac
BOOL MACGetHeader(MAC_ADDR *remote, int8* type);
WORD MACGetArray(BYTE *val, WORD len);
void MACDiscardRx(void);
void MACDiscardTx(BUFFER buff);
void MACPutHeader(MAC_ADDR *remote,
BYTE type,
WORD dataLen);
void MACSetRxBuffer(WORD offset);
void MACSetTxBuffer(BUFFER buff, WORD offset);
void MACReserveTxBuffer(BUFFER buff);
BOOL MACIsTxReady(BOOL HighPriority);
WORD MACGetFreeRxSize(void);
void MACFlush(void);
BYTE MACGet(void);
void MACPut(int8 val);
void MACPutArray(BYTE *val, WORD len);
void MACInit(void);
BUFFER MACGetTxBuffer(BOOL HighPriority);
///timer
int8 event_second_count;
void timer_init(void);
int1 timer_event(void);
void timer_set_s(int s);
int1 _timer_enabled=0;
#define timer_disable() _timer_enabled=0
#define timer_enable() _timer_enabled=1
#endif |
This is the pppwrap.h.I can't see any problem here.
By the way I try to find unmatched parenthesis in the file but didn't found one that is unmatch.
Thank you
|
|
|
syide
Joined: 10 Nov 2008 Posts: 16 Location: Malaysia
|
|
Posted: Thu Feb 19, 2009 4:36 am |
|
|
This one after I add ";" after PPP_BUFFER_CHOICE ppp_active_buff;
#locate ppp_active_buff=0x20
But still leave one more error that "Expecting a ."
|
|
|
Ttelmah Guest
|
|
Posted: Thu Feb 19, 2009 4:42 am |
|
|
I must admit, I'd be 'chary' about using an enumerator in a typedef like this. I'd not be 'confident', that CCS would treat PPP_BUFFER_CHOICE as the typedef identifier, rather than the enumerator identifier...
Personally, 'knowing CCS', I'd declare the enumerator first, separately, with an enumerator identifer, and then do the typedef with this.
As a general 'good C practice' comment, I'd always bracket the numeric values in defines (read the original K&R book for 'why').
Again though, you may well be having to look 'further back'. What is 'BUFFER', and the defintiion for ppp_active_buffer.
Seriously, nobody here, is going to keep reading, pages and pages of code, looking for this error, you_ are going to have to do it, but you really do need to have your 'debuggers' hat on, and query everything.
Best Wishes |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Feb 19, 2009 5:33 am |
|
|
It's a bit tricky, but in a few moments, you can find out, that the problem is caused by the combination of a binary (int1) enum type and the #locate statement. This may be considered a CCS C bug, however, an int1 has no unequivocal address at a byte boundary. A more specific error message would be pleasant anyway.
As a workaround, you can add a dummy value to the enumeration to force an int8 variable, or declare your variable as int8 and use it together with an enum value.
Code: | typedef enum __PPP_BUFFER_CHOICE {PPP_RX_ACTIVE, PPP_TX_ACTIVE, E_DUMMY} PPP_BUFFER_CHOICE; |
|
|
|
syide
Joined: 10 Nov 2008 Posts: 16 Location: Malaysia
|
|
Posted: Thu Feb 19, 2009 6:19 am |
|
|
Thnk FvM,
The code u gave work.
Also to Ttlemah for ur advise. |
|
|
|
|
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
|