CW 5.1 Error Messages

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

CW 5.1 Error Messages

ソリューションへジャンプ
3,140件の閲覧回数
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
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,417件の閲覧回数
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 件の賞賛
返信
3 返答(返信)
1,418件の閲覧回数
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 件の賞賛
返信
1,417件の閲覧回数
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 件の賞賛
返信
1,417件の閲覧回数
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