cancel
Showing results for 
Search instead for 
Did you mean: 

missing prototype and inline function issues in STVD

dongdong chen
Associate II
Posted on February 27, 2018 at 11:41

Hi!

When I called assert() funtion, it always reported an error as followed. I had included the head file named assert.h.

   #error cpstm8 modbus\rtu\mbrtu.c:168(4) missing prototype

   #error cpstm8 modbus\rtu\mbrtu.c:248(4) missing prototype

   #error cpstm8 modbus\rtu\mbrtu.c:311(4) missing prototype

   #error cpstm8 modbus\rtu\mbrtu.c:369(8) missing prototype

code:

#include <assert.h>

... ...

assert( eSndState == STATE_TX_IDLE );

And when I used inline keyword , I met the errors and warns as follewed:

#warning cpstm8 port\porttimer.c:63(0+6) implicit int type in global declaration

#error cpstm8 port\porttimer.c:63(0+6) missing ;

#warning cpstm8 port\porttimer.c:70(38) implicit int type in global declaration

#error cpstm8 port\porttimer.c:71(17) missing )

#warning cpstm8 port\porttimer.c:71(23) implicit int type in global declaration

#error cpstm8 port\porttimer.c:73(18) missing ;

......

code:

inline void

vMBPortTimersEnable( )

{

/* Enable the timer with the timeout passed to xMBPortTimersInit( ) */

/* Clear TIM2 update flag */

TIM2_ClearFlag(TIM2_FLAG_UPDATE);

/* Enable update interrupt */

TIM2_ITConfig(TIM2_IT_UPDATE, ENABLE);

TIM2_SetCounter(0x00);

/* Enable TIM2 */

TIM2_Cmd(ENABLE);

}

It have taken my whole day, but can't solve. Help me! THX       T.T

2 REPLIES 2
Philipp Krause
Senior II
Posted on February 27, 2018 at 15:24

While you seem to be using STVD and Cosmic, that doesn't matter much here. Your issues are with the C standard, and you would run into the same problem with IAR or SDCC.

Of course you need assert.h for assert(). It needs to come from somewhere and assert.h is where is should be according to the C standard (section 7.2 in the ISO C11 standard).

You inline function seems to take no parameters. You need to indicate that using void, ie.e.

inline void

vMBPortTimersEnable(void)

{

Unlike C++, you can't just leave out the void in C.

Philipp

P.S.: I don't remember if Cosmic supports inline, but if it does, it might need a command line parameter to enable the ISO C99 standard (AFAIR Cosmic uses the ANSI/ISO C90 standard by default, while for IAR the default is ISO C99, and for SDCC the default is ISO C11; inline was introduced in ISO C99).

Posted on February 28, 2018 at 10:01

Thanks for the reply!

It has taken me too much time.....So I have given it up....TT

Finally, I removed the inline keyword to solve inline issue, and removed assert.h and redefined assert() macro to solve missing prototype issue.