Page 1 of 1

Failed to compile usb_lld.c in Keil

Posted: Sun Mar 08, 2015 4:23 pm
by daemon
Hello!

The last stable version 2.6.7 and unstable version 2.6.8 has the same compilation error in Keil MDK 5:
compiling usb_lld.c...
os\hal\platforms\STM32\OTGv1\usb_lld.c(539): warning: #111-D: statement is unreachable
__set_BASEPRI(0);
os\hal\platforms\STM32\OTGv1\usb_lld.c(1266): error: #268: declaration may not appear after executable statement in block
uint32_t pcnt = (isp->txsize + usbp->epc[ep]->in_maxsize - 1) /
os\hal\platforms\STM32\OTGv1\usb_lld.c: 1 warning, 1 error


NOTE: STM32_USB_OTGFIFO_FILL_BASEPRI was defined in mcuconf.h

"uint32_t pcnt" must be defined at the start of a function. (Its not a C++ code :D )

Another issue is that __set_BASEPRI(0); is unreachable in the code and it (seems) to hang the system when STM32_USB_OTGFIFO_FILL_BASEPRI is not 0.

Re: Failed to compile usb_lld.c in Keil

Posted: Mon Mar 16, 2015 11:52 am
by GunterO
I think you need to enable the -C99 option in µVision.
The error "declaration may not appear after executable statement in block" is typical when the support for the ISO C99 standard is not enabled.

Re: Failed to compile usb_lld.c in Keil

Posted: Mon Mar 16, 2015 12:21 pm
by daemon
I think you need to enable the -C99 option in µVision.

Yes, you are right. The question arise because this was the only one place in the code with such error. Maybe because ChibiOS is ANSI C compliant.

Other question regarding __set_BASEPRI(0); is still actual.

Re: Failed to compile usb_lld.c in Keil

Posted: Mon Mar 16, 2015 12:28 pm
by Giovanni
Hi,

I forgot about this, it is misplaced, will fix in next version.

Giovanni

Re: Failed to compile usb_lld.c in Keil

Posted: Mon Mar 16, 2015 12:33 pm
by daemon
OK, thanks Giovanni!