|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
C18 v2.4 -- Syntax error where there is no syntax error
This is really weird! When I try to compile some code, I get a syntax error where there is no error at all! Like, in the header file for serial_ports.h (Kevin's code), the compiler dies here,
// if needed, declare functions and global variables that // are specific to serial port one receiver functionality #ifdef ENABLE_SERIAL_PORT_ONE_RX --> void Init_Serial_Port_One(void); So I start removing files (carefully), and at each compile it craps out at some (seemingly) random point in a header file. Anyone experienced this? Anyone have an idea as to what is wrong here? At first I thought I had to switch to the large code model (>64KB), but that didn't help anything. |
|
#2
|
|||
|
|||
|
Re: C18 v2.4 -- Syntax error where there is no syntax error
I had the same problem last year. I think it can be resolved by simply checking the #include statements in all of your source files to be sure functions that are being referenced are included, and non used headers are not included. I know it seems kind of obvious, but give it a try.
|
|
#3
|
||||
|
||||
|
Re: C18 v2.4 -- Syntax error where there is no syntax error
Quote:
Thanks. |
|
#4
|
|||
|
|||
|
Re: C18 v2.4 -- Syntax error where there is no syntax error
I had this same problem dogging me not 2 hours ago, look at your brackets in that file, not just what you edited but the WHOLE file. hope this helps!
|
|
#5
|
||||
|
||||
|
Re: C18 v2.4 -- Syntax error where there is no syntax error
I've been having the same problem. The error comes up when it is compiling user_routines.c so I looked through the entire file for any missing semicolons or brackets. I didn't find anything wrong in it. I think the compiler may just be giving me the wrong location of the error so I guess I'll have to look throught the whole code. Until then any suggestions will be greatly appreciated.
|
|
#6
|
|||
|
|||
|
Re: C18 v2.4 -- Syntax error where there is no syntax error
One trick you can try is adding:
#ifdef NEVER : . #endif around chunks of your code and recompile. When I'm totally lost on how to isolate the issue this allows me to remove chunks of code from being compiled. If the problem still exists, I add the above to still more code. Bud |
|
#7
|
|||||
|
|||||
|
Re: C18 v2.4 -- Syntax error where there is no syntax error
This is a pretty common problem particular to include files.
The important clue is that the error gets flagged on the first line of some include file when the compiler finally figures out that you haven't closed a bracket somewhere previous. The key is to remember that all your #include's are just inserting all that text into a single massive file that's then passed to the compiler, so the error is really getting flagged in the middle of that big file, not in the single include file spit out in the error message. So thinking about it as one huge file rather than a series of includes... What it really means is there is an error in another included file or other text before the include file that shows the error just like in regular code when it's often the line or block of code before. If the error occurs in your very first include then the cause is often accidental characters typed at the very top of your source file or an unclosed comment field. P.S. Nice search skills by the way to rediscover this thread among thousands. Last edited by Mark McLeod : 12-01-2007 at 09:49. |
|
#8
|
||||
|
||||
|
Re: C18 v2.4 -- Syntax error where there is no syntax error
I found the problem. In the very last line of the previous included file a semicolon was missing. I still don't know why the error only shows up on the first function prototype after it occurs instead of the next line. But now that I fixed it it doesn't really matter. Thanks for the help!
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C18 v2.4 compiler location | b_mallerd | Programming | 1 | 14-12-2005 16:43 |
| Syntax Error: externs, structs, and macros | Astronouth7303 | Programming | 3 | 16-02-2005 15:39 |
| syntax error using enum{} | gnormhurst | Programming | 8 | 07-02-2005 14:25 |
| Routine declaration syntax error (Or: Where's wlado?) | Astronouth7303 | Programming | 15 | 24-03-2004 05:51 |