Unable to include stdlib.h

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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.

   

 

   

Thanks

0 Likes
1 Solution
Anonymous
Not applicable

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?

View solution in original post

0 Likes
4 Replies
Anonymous
Not applicable

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?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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 ++)

   

 

   

Bob

Anonymous
Not applicable

 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

Anonymous
Not applicable

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

0 Likes