cancel
Showing results for 
Search instead for 
Did you mean: 

Prevent heap usage with IAR

Dennis Jackson
Associate
Posted on January 19, 2017 at 01:28

The Keil uVision IDE/compiler chain has a `&sharppragma` for preventing heap usage; see 

http://www.keil.com/support/man/docs/armlib/armlib_chr1358938927854.htm

. The great thing about this is that the linker fails if anyone (or a library) attempts to use the heap.  I've searched through the IAR documentation and haven't seen an equivalent method of preventing inadvertent heap usage.  I've looked at the linker options as well.  Is there a way to prevent compiling/linking if a routine tries to use the heap with the IAR toolchain?

#iar #heap
1 REPLY 1
Dennis Jackson
Associate
Posted on June 24, 2017 at 04:25

From an FAE at IAR:

Options:

1. Rewriting the malloc() and free() functions in the library to generate ERROR message every time it used.

2. Redirecting these functions to other functions that will do nothing or generate errors by using command line options like “ –redirect malloc=nomalloc�? and your nomalloc() will be used every time that someone uses malloc().

3. Creating a function using prototype.

The following link describes all three ways:

/external-link.jspa?url=https%3A%2F%2Fwww.iar.com%2Fsupport%2Fresources%2Farticles%2Foverriding-and-redirecting-library-modules%2F