cancel
Showing results for 
Search instead for 
Did you mean: 

assert_param() problem

colin239955_st
Associate II
Posted on September 02, 2011 at 11:10

From what I can see this is used to check in parameters into the c library functions.

I've tried to add this to a header file but when I do so the compiler creates many unrelated errors.

This is what I am adding:-

Has anyone had the same problem?

I'm putting it into the top .h file

#define USE_FULL_ASSERT    (1)

/* Exported macro ------------------------------------------------------------*/

#ifdef  USE_FULL_ASSERT

/**

  * @brief  The assert_param macro is used for function's parameters check.

  * @param expr: If expr is false, it calls assert_failed function

  *   which reports the name of the source file and the source

  *   line number of the call that failed.

  *   If expr is true, it returns no value.

  * @retval : None

  */

#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))

/* Exported functions ------------------------------------------------------- */

void assert_failed(uint8_t* file, uint32_t line);

#else

#define assert_param(expr) ((void)0)

#endif /* USE_FULL_ASSERT */
4 REPLIES 4
jdf25252
Associate II
Posted on September 02, 2011 at 17:07

First, if you add code that causes errors then they are by definition RELATED.

Second, the assert_param() macro is NOT used in checking the 'C' library function parameters and is totally unrelated to anything provided by Cosmic.  It is used instead in verifying the parameters in the STM8FirmwareLibrary provided by ST.  (a library which in my own opinion is worse then useless as you can see by all the problems people are having with it).

The assert_param macro is defined in ''stm8s_conf.h'' which should be loaded from stm8s.h.  All you need to do to enable it is to define USE_FULL_ASSERT..

colin239955_st
Associate II
Posted on September 06, 2011 at 11:26

H John,

I know why the assert is used but I just think it's the way I have my project set up I'm going to delete any instances of the assert just to get it going. There should be a doc on seting up the projects in plain terms that normal people can understand. ST want you to make them money by using their micros but they fail to tell you how to do this correctly it requires alot more than a datasheet. I tried what you said but that didn't work, I've looked at the toggle example and the file structure look very differant to mine. Thnaks for the reply.

kuntay
Associate
Posted on October 08, 2011 at 14:02

uncomment #define USE_STDPERIPH_DRIVER in stm8s.h

mighel84
Associate II
Posted on October 18, 2011 at 19:14

It's not useless, it's may be usebad. 🙂

assert_param will catch wrong parameters that could be passed to register by stlibrary functions. If not used, you could have bad things.

Try out the #define location with ''find in all files'' and disable it.