4 Replies Latest reply on Mar 1, 2012 12:18 AM by richard.park

    Unable to include stdlib.h

    richard.park

      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

        • 1. Re: Unable to include stdlib.h
          gautamd_41

          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?

          • 2. Re: Unable to include stdlib.h
            user_1377889

            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

            1 of 1 people found this helpful
            • 3. Re: Unable to include stdlib.h
              udayanu_51

               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

              1 of 1 people found this helpful
              • 4. Re: Unable to include stdlib.h
                richard.park

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