I’ve now written some drive code for our robot and I wanted to compile it to make sure it worked. I didn’t have the cd that came in the kop so I downloaded the student trial of the C18 complier and installed it. When I tried to compile my code I got this error.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21\camera.o” is up to date.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21\camera_menu.o” is up to date.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21\eeprom.o” is up to date.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21\ifi_startup.o” is up to date.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21\ifi_utilities.o” is up to date.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21\main.o” is up to date.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21\serial_ports.o” is up to date.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21 erminal.o” is up to date.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21 racking.o” is up to date.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21 racking_menu.o” is up to date.
Make: The target “C:\Documents and Settings\David Pick\Robotics\frc_camera_21\user_routines.o” is out of date.
Executing: “C:\mcc18\bin\mcc18.exe” -p=18F8722 “user_routines.c” -fo=“user_routines.o” -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -nw=2066 -D_FRC_BOARD
MPLAB C18 v3.02 (demo)
Copyright 1999-2005 Microchip Technology Inc.
Days remaining until demo becomes feature limited: 59
C:\Documents and Settings\David Pick\Robotics\frc_camera_21\user_routines.c:367:Error: syntax error
Halting build on first failure as requested.
BUILD FAILED: Mon Jan 22 20:53:36 2007
Except the only code on line 367 is:
char target;
Which also happens to be the first line of code I wrote.
Anybody know whats going on? Thanks.
You’ll have to post more code before and after that, preferably the entire function.
One possibility is that you are declaring variables in the middle of the function, which is legal in C++ but not in C.
Also, The C18 compiler version 3.x won’t work with the existing libraries. You must use the version 2.4 that came in the kit. That probably isn’t causing the syntax error, but will keep you from successfully compiling farther down the road.
It’s a bad term for the error, but MPLAB will call any variable declaration, not at the beginning of the routine, a syntax error. If that’s not it, check all your preprocessor directives. There may be something put in by the preprocessor that’s causing the error, or perhaps the term target is #defined as something already.
You need to use the C suite from the KOPs. There are incompatibilities between the suite provided in the KOP which is an older version of compiler/linker and the current versions from Microchip’s website.
As he said, what is probably going on is that you are declaring a new variable after some code. In C90 (I think this is what mcc18 uses) new variable declarations must go at the start of a block (right after the ‘{’). Try that and see if it helps.