Article ID: 000083955 Content Type: Troubleshooting Last Reviewed: 09/11/2012

Can I use the Newlib assert() function for Nios II software projects compiled with the Small C library flag?

Environment

BUILT IN - ARTICLE INTRO SECOND COMPONENT
Description

The Newlib assert() function calls the fiprintf function which is not supported by the Nios® II Small C library.  However, you can use assert() by modifying it to use fprintf instead of fiprintf.  To do this copy the <nios2 install directory>/bin/nios2-gnutools/src/newlib/newlib/libc/stdlib/assert.c file into your system library project.  Then modify the call to fiprint to call fprintf instead.  In other words, change the following code:

     (void)fiprintf(stderr, "assertion \%s\ failed: file \%s\, line %d\n", failedexpr, file, line);

to read:

     (void)fprintf(stderr, "assertion \%s\ failed: file \%s\, line %d\n", failedexpr, file, line);

Then save the modified assert.c file and recompile your project.  The compiler will now pick up the local copy of assert.c instead of the library version.

Related Products

This article applies to 1 products

Intel® Programmable Devices