cancel
Showing results for 
Search instead for 
Did you mean: 

NDEBUG doesn't seem to work as expected

Konami
Senior II

I'm working through some code size optimization efforts and noticed that our list file includes some calls to __assert_func. We're not using asserts in our codebase so I'm guessing one of the standard libs is using it. I checked and we have defined NDEBUG in the project properties. If I redefine __assert_func as an empty function, the calls disappear and we get back 4kB of flash. Any idea why it's being linked?

3 REPLIES 3

Preprocessor defines aren't going to impact pre-compiled components.

Grep the libraries.

See what's calling it from a disassembly/listing. Perhaps the linker has some verbose mode or output?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

If I redefine __assert_func as an empty function, the calls disappear

Probably, effect of link-time optimization (LTCG)

ST libraries use error handler named assert_failed, not assert_func. The latter can come from the newlib in the latest CubeIDE toolchain build...

Konami
Senior II

Ah, yes I overlooked that these are precompiled and therefore wont care about my flags. Is there any way to disable the newlib asserts or is overwriting the function, and relying on flto the best solution?