CW 5.1 Error Messages

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CW 5.1 Error Messages

Jump to solution
2,431 Views
admin
Specialist II
I get the error: "C2801: ')' missing" when I try to compile the following code segment.  I am using CW5.1 with the latest patches and am targeting the JB16. 
 
/******************************************************************************
 cputchar
  wait for RTS then send a single byte to the SCI transmitter */
 
char cputchar(unsigned char scbyte){
 if (ReadyToSend()) return 1;  // wait for TX Empty bit to set
 SCDR = scbyte;     // send char out TX
 return 0;
}
 
/****************************************************************************
 cputch
 check for end of line marker and send CR/LF, else, send input char */
 
void cputch(unsigned char ch){
 if (ch == ('\n')){
  cputchar(LF);
  cputchar(CR);
 } else {
  cputchar(ch);
 }
}
/*void cputch(unsigned char ch){
 unsigned char i, j;
 
 i = LF;
 j = CR;
 if (ch == '\n') {
  cputchar(i);
  cputchar(j);
 }
}*/
/****************************************************************************
I have included all the .h files necessary to define program variables including the sci.h file where I have defined LF and CR. 
 
The code segment I have commented out compiles with no errors.  Why am I getting this error?  Why will this code segment not compile?  Any suggestions will be appreciated. 
 
Thanks
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
708 Views
rocco
Senior Contributor II
Hi Spencer,

As Erich pointed out, the problem is likely related to the definitions of CR or LF. I've had that error.

Specifically, the definition should be:

#define CR 0x0d

but a common error that I make is to write it:

#define CR 0x0d;

The extra semicolon at the end of the macro will get substituted as well, causing the compiler to complain that it hasn't yet seen the closing parentheses.

View solution in original post

0 Kudos
Reply
3 Replies
709 Views
rocco
Senior Contributor II
Hi Spencer,

As Erich pointed out, the problem is likely related to the definitions of CR or LF. I've had that error.

Specifically, the definition should be:

#define CR 0x0d

but a common error that I make is to write it:

#define CR 0x0d;

The extra semicolon at the end of the macro will get substituted as well, causing the compiler to complain that it hasn't yet seen the closing parentheses.

0 Kudos
Reply
708 Views
admin
Specialist II
Rocco
 
You hit the nail on the head.  I have been having other, similar, errors and when I removed the semi-colon the problems disappeared.
 
Thanks for the info.
 
Spencer
 
0 Kudos
Reply
708 Views
BlackNight
NXP Employee
NXP Employee
Hello,
I suggest you compile your source file with the -Lp option to produce a preprocessor file. You then maybe will see the problem in the preprocessor file itself, or simply try to compile the preprocessor output itself.
I think you may have something screwed up with your macros, and producing the preprocessor file will let you see what happend.

Hope it helps,
Erich