Error: missing binary operator before token "int"

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm looking for a work around to avoid the following compiler error:

vs1011.h:109:7: missing binary operator before token "int"

The error occures with the following preproccessor code:

105 #ifdef VS1011_USE_CLKDOUBLER
106   #define VS1011_CLOCKFVALUE   (unsigned int)(VS1011_XTAL/2000)+0x8000
107 #else
108   #define  VS1011_CLOCKFVALUE  (unsigned int)VS1011_XTAL/2000
109   #if VS1011_CLOCKFVALUE > 32767
110     #error Invalid VS1011_CLOCKFVALUE - Value greater 32767.
111   #endif
112 #endif

I searched Google for the error and got only one hit, the avr-gcc-list:
http://lists.gnu.org/archive/htm...

The code works without cast for the calculation.
VS1011_XTAL is defined like 12288000UL and VS1011_CLOCKFVALUE should be an unsigned int.

Any ideas?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You cannot use C typecasts in CPP calculations.

Divide the VS1011_CLOCKFVALUE into two parts, one that just
performs the calculation, and is used only internally (it would default
to unsigned long type when used in C code), and a second one
that includes the typecast.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lesson learned ;)

Thanks Jörg