Re: What does "error: expected expression before '/' token" really mean?

Senthil Kumar Selvaraj <[email protected]>
Newsgroups gmane.comp.hardware.avr.gcc
Message-ID <[email protected]>
On Wed, Jul 23, 2014 at 03:22:06PM -0400, Bob Paddock wrote:
>  Can someone tell me please what this error really means?:
> 
> "error: expected expression before '/' token"
> 
> Googling says it is from using C++ style comments, in C code, which is
> not the case here.
> 
> I can find no place where there actually *is* a '/' token in relation
> to the error:
> 
> avr-gcc (AVR_8_bit_GNU_Toolchain_3.4.4_1229) 4.8.1
> 
>  [GCC]     : Compiling C File: "Version/version.c" to
> "[../Firmware_Project/Project/Object/]
> ../Firmware_Project/Project/Object/Version/version.o"
> 
> J:\APPS/AVR_TC_344_1229/bin/avr-gcc [see command line below]
> <command-line>:0:11: error: expected expression before '/' token
> 
> Version/version.c:25:48: note: in expansion of macro 'MODEL_STR'
>  const char Model_Prj_str[]      VERSION_INFO = MODEL_STR;
> /* Model */
>                                                 ^
> This is how MODEL_STR has been defined for a very long time (changed
> the project name for posting here):
> 
> -DMODEL_STR=\"Project\"
> 
> This has something to do with the build system and not the actual
> source code, as the build system is what was recently changed.
> The error goes away if I take the multiplication out of this line:
> 
> CDEFS += -DALARM_SET_POINT_MAX=(15U*60U)
> 
> so it just reads as :
> 
> CDEFS += -DALARM_SET_POINT_MAX=15
> 
> That definition is not used, nor even included in anyway outside of
> the command line, in the file that is complaining about the '/' token.
> 
> I can invoke the same error by adding parentheses around this line:
> 
> CDEFS += -DSCRN_Y_BYTES=$(SCRN_HEIGHT)/8U
> 
> to yield:
> 
> CDEFS += -DSCRN_Y_BYTES=($(SCRN_HEIGHT)/8U)
> 
> This is the compile command line, split on spaces due to its length to show it
> here, normally it would be one LONG line:
> J:\APPS/AVR_TC_344_1229/bin/avr-gcc
> -c
> -mmcu=atxmega128a1
> -DSCRN_HEIGHT=32U
> -DSCRN_LENGTH=120U
> -DSCRN_LEFT=0U
> -DSCRN_TOP=0U
> -DSCRN_RIGHT=120U-1U
> -DSCRN_BOTTOM=32U-1U
> -DSCRN_X_BYTES=120U
> -DSCRN_Y_BYTES=32U/8U
> -DMODEL_NAME_TEXT=\"CompanyName\"
> -DLOGO_MODEL_NAME=\"Name\"
> -DLOGO_WIDTH=120U
> -DLOGO_HIGHT=21U
> -DLOGO_TEXT_POSITION_X=SCRN_LEFT+1U
> -DLOGO_TEXT_POSITION_Y=SCRN_TOP+20U
> -DLOGO_TEXT_FONT_SIZE=FONT_DINA_SIX_DOT
> -DPCB_REV_A=1U
> -DALARM_SET_POINT_MAX=15*1
> -DMODEL_STR=\"Project\"
> -DFIRMWARE_NUMBER=0U
> -DFIRMWARE_REV_STR=\"v0.0.0\"
> -DFIRMWARE_REV_NUMBER_STR=\"000\"
> -DBACKLIGHT_BUTTON_TIME=10U
> [Many other -D's snipped]
> -IVersion/
> [Many other -I's snipped]
> -I.
> -g
> -Os
> -funsigned-char
> -funsigned-bitfields
> -std=gnu99
> -Wa,-adhlns=../Firmware_Project/Project/Object/Version/version.lst
> -DF_CPU=4000000UL
> -Datxmega128a1
> -DNEW_BUILDNUMBER=911
> -DNEW_BUILDNUMBER_TEXT=\"911\"
> -MMD
> -MP
> -MF ../Firmware_Project/Project/Dep/version.o.d
> Version/version.c
> -o ../Firmware_Project/Project/Object/Version/version.o

Perhaps the shell is kicking in and transforming the arithmetic
expression in some way before it is passed to the compiler? Does
wrappping the expression or the -D option itself in single quotes help?
> 
> _______________________________________________
> AVR-GCC-list mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.