Electronics > Projects, Designs, and Technical Stuff

Error While Trying To Compile Code

(1/3) > >>

Lance:
I'm trying to write a program for a PIC16F917. Everything was going good, until I got this error message:


--- Code: ---Error   [285] C:\Program Files\HI-TECH Software\PICC\9.81\include\pic16f917.h; 111.14 no identifier in declaration
Error   [314] C:\Program Files\HI-TECH Software\PICC\9.81\include\pic16f917.h; 111.14 ";" expected

********** Build failed! **********

--- End code ---

I looked at the header in question and couldn't find any errors in it.


--- Code: ---// Register: STATUS
volatile unsigned char           STATUS              @ 0x003;
// bit and bitfield definitions
volatile bit CARRY               @ ((unsigned)&STATUS*8)+0;
volatile bit DC                  @ ((unsigned)&STATUS*8)+1;
volatile bit ZERO                @ ((unsigned)&STATUS*8)+2; <---This is the line the error occurs on.
volatile bit nPD                 @ ((unsigned)&STATUS*8)+3;
volatile bit nTO                 @ ((unsigned)&STATUS*8)+4;
volatile bit IRP                 @ ((unsigned)&STATUS*8)+7;
volatile bit RP0                 @ ((unsigned)&STATUS*8)+5;
volatile bit RP1                 @ ((unsigned)&STATUS*8)+6;

--- End code ---

Does anyone know where this is coming from?

adam1213:
try commenting out where you include that file and check if any of the errors that you get are not related to that file.
edit after original post modified: Maybe "ZERO" is being used for something else

Lance:
That did it. This is a section from main.h


--- Code: ---/* Numbers */
//#define ZERO   0x00
#define ONE    0x01
#define TWO    0x02
#define THREE  0x03
#define FOUR   0x04
#define FIVE   0x05
#define SIX    0x06
#define SEVEN  0x07
#define EIGHT  0x08
#define NINE   0x09

--- End code ---
So I guess zero was already being used. Looks like I need to find something else to use for that definition.

Now to figure out why the device refuses to do anything. This is the first program I've compiled using the Hi-Tech C compiler. The one I used at school vastly simplifies things, which makes it somewhat useless.

adam1213:
is there a reason that you are using defines for numbers?
 - normally defines are used instead of a number to make the code easier to read and maintain eg "#define BLINK_FREQUENCY 1" However something like "#define ONE 0x01" doesn't achieve this.

Also I am curious about why you are using "0x" before the numbers - try defining 10 then using it and check if you get the result you expect.

jinuq:
0x is used for hexadecimal notation in C.

In his use it would be unnecessary. 0x10 and 10 are different numbers.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version