Felix Straube

Question about #define

Discussion created by Felix Straube on Oct 1, 2008
Latest reply on Oct 1, 2008 by Felix Straube
Just another dumb question:

I am using Codewarrior 6.2 Release, build 8127, and targeting a HC908AP32.

If I try to compile the folowing code i get a "C2801: ')' missing" error, pointing at the line "if (x + MAX_BUFFER_LENGTH)" in the foo() function.

#include <hidef.h> /* for EnableInterrupts macro */#include "derivative.h" /* include peripheral declarations */void MCU_init(void); /* Device initialization function declaration */#define MAX_BUFFER_LENGTH 10;unsigned char x;void foo(void){  if (x + MAX_BUFFER_LENGTH)  {    x++; // do something  }}void main(void) {  MCU_init(); /* call Device Initialization */  foo();  for(;;)   {    } }

My original code was a little different and I lost some time until i realized that the semicolon at the end of the line:
define MAX_BUFFER_LENGTH 10;<---
was the problem.

My question is, if the compiler is working correctly or is it supposed  to warn that there is a  misplaced semicolon? Just wondering because i lost almost 30 minutes until i found the error.
Thanks in advance

Message Edited by nfxs on 2008-10-01 02:45 AM

Message Edited by nfxs on 2008-10-01 02:46 AM