You are here

Unable to include stdlib.h | Cypress Semiconductor

Unable to include stdlib.h

Summary: 4 Replies, Latest post by r2park on 01 Mar 2012 12:18 AM PST
Verified Answers: 3
Last post
Log in to post new comments.
r2park's picture
5 posts

I am trying to build code for the Psoc5 that uses the itoa function from stdlib.h.

I have the #include <stdlib.h> at the beginning of main.c but It is not being included and I am getting errors related to

undefined references to itoa. Do I need to explicitly set the include path in the build settings? and if so where would they be located.



dasg's picture
Cypress Employee
730 posts

Hi r2park,


If you are intending to convert from integer to ASCII string, then did you try using the sprintf( ) function to do the same?

user_1377889's picture
9307 posts

Well, as a matter of fact I use "#include <stdlib.h>" in a PSoC5 - project without any error-message. You should check for

An installation-error

An error occuring BEFORE the #include (mismatched brckets, missing semicolon...)


A search reveiled 4 files named "stdio.h" one for each compiler (Keil, GNU 4, GNU generic, GNU ++)




uday's picture
Cypress Employee
569 posts

 Hello there. As Bob has pointed out, you can include stdlib.h without any issues. However, note that i2a may not be a standard C function. The best possible solution is to use, sprintf if what you are trying to achieve is integer to ascii conversion. 

You can do it as follows, 


sprintf(buffer, sizeof(buffer), "%d", i);

your ascii result is now present in the buffer. You might have to include stdio.h in order to use sprintf

r2park's picture
5 posts

Thanks, the sprintf function works great. I had assumed that the itoa was a standard function due to atoi being in stlib.h

Log in to post new comments.