Shop OBEX P1 Docs P2 Docs Learn Events
Have not used PropGCC for awhile? — Parallax Forums

Have not used PropGCC for awhile?

RsadeikaRsadeika Posts: 3,837
edited 2015-06-17 06:59 in Propeller 1
I have the latest SimpleIDE RC 2 for Windows installed. Below I was just testing out the simple itoa() function, and the program does not compile, what the heck is going on with the latest version of SimpleIDE. I double checked to make sure I was using itoa() correctly, which I am, but the error is telling me that it cannot find itoa()?

If this is not just a simple error on my part, and there were changes made to the way SimpleIDE works, I would think that Parallax would be nice enough to at least give a slight indication that there are major changes to be expected to the way SimpleIDE will work. To take it one step further, if Parallax is dumping SimpleIDE, please let us know, so we can make other arrangements. Thank you for your consideration.

Ray

/*
  test2.c
  http://learn.parallax.com/propeller-c-tutorials 
*/
#include <stdio.h>
#include <stdlib.h>


int main()                                    // Main function
{
  // Add startup code here.
  int first;
  char second[6];
  
  first =13076;
  itoa(first,second,10);
  printf("?%s",second);
 
  while(1)
  {
    // Add main loop code here.
    
  }  
}
Project Directory: D:/programming/PropGCC/test2/

SimpleIDE Version 1.0.2
C:/Users/ray/Documents/SimpleIDE/Learn/Simple Libraries/
C:/Users/ray/Documents/SimpleIDE/ Updated on: 2015-06-13

propeller-elf-gcc.exe -v GCC 4.6.1 (propellergcc_v1_0_0_2408)
propeller-elf-gcc.exe -I . -L . -o cmm/test2.elf -Os -mcmm -m32bit-doubles -fno-exceptions -std=c99 test2.c -lm
test2.c: In function 'main':
test2.c:16:3: warning: implicit declaration of function 'itoa' [-Wimplicit-function-declaration]
C:\Users\ray\AppData\Local\Temp\ccC8ebpW.o: In function `_main':
(.text+0xe): undefined reference to `_itoa'
collect2: ld returned 1 exit status
Done. Build Failed!

Check source for bad function call or global variable name `_itoa'

Comments

  • ersmithersmith Posts: 6,053
    edited 2015-06-17 04:32
    itoa is not a standard C function, and as far as I know it has never been supported by PropGCC. I guess it's possible that one of the libraries that comes with SimpleIDE may have it (I don't tend to use SimpleIDE myself), but in that case you'll need to include the appropriate header file for it.

    Instead of itoa you could use sprintf:
    sprintf(second, "%d", first);
    
  • RsadeikaRsadeika Posts: 3,837
    edited 2015-06-17 04:46
    itoa is not a standard C function, and as far as I know it has never been supported by PropGCC.

    A couple of years back, I remember using itoa and atoi, with a program that I was working on, yes it was SimpleIDE, and the functions were there, which worked. So, it seems to me somebody is cleaning house, and not letting anybody know about what has been removed. Now I am wondering what else is missing, or is this to be the "New Adventures with SimpleIDE" time?

    Ray
  • Dave HeinDave Hein Posts: 6,347
    edited 2015-06-17 04:47
    I looked at the source code for the PropGCC libraries, and itoa is not in it. I also tried compiling the program with gcc under Cygwin, and I get the same error. As Eric said, itoa is not a standard C function.
  • RsadeikaRsadeika Posts: 3,837
    edited 2015-06-17 05:09
    Maybe it has been more than a couple of years back, but I do know that I had used it with SimpleIDE, and at that time it worked as expected. Maybe at some point since then, Parallax told jazzed to get rid of it, and they did not let anybody else know about it being removed. I am not trying to make a big deal out of this, but it seems like, for example, itoa and atoi, are readily available in other C implementations, I think? Does anybody have a list of expected functions that are not supported in SimpleIDE?

    Ray
  • ersmithersmith Posts: 6,053
    edited 2015-06-17 05:23
    Maybe you're thinking of atoi()? That is supported. But AFAIK itoa() has never been in any of the PropGCC libraries (and I wrote the atoi, strtol, and printf functions, so I think I would have noticed that one).

    As far as what functions should be supported, all of the ones in the C standard are. If you look online at e.g, www.cplusplus.com for a function, and see whether it is standard or not, that will pretty much tell you whether it should be in the library. itoa() is marked as non-standard, and googling it leads one to find that it's not present in Linux (for example).
  • RsadeikaRsadeika Posts: 3,837
    edited 2015-06-17 05:43
    fyi, the program below, using sprinti(), which is in the simpletools lib, you get a Code size 13924.

    Using the program below with sprintf(), you get a Code size 13,824, with the substantial general code overhead, every little byte saved helps. I am assuming that both of these versions are accomplishing the same thing?

    Yes I do use cplusplus a lot, as a reference, the little examples that are included with the function explanation is very useful.

    Ray
    */
    //#include <stdio.h>
    //#include <stdlib.h>
    #include "simpletools.h"
    
    
    int main()                                    // Main function
    {
      // Add startup code here.
      int first;
      char second[6];
      
      first =13076;
      pause(1000);
      sprinti(second,"%d",first);  // Convert interger to string(ascii)
      printf("?%d",second);
    
      return 0;
     
      while(1)
      {
        // Add main loop code here.
        
      }  
    }
    
  • LeonLeon Posts: 7,620
    edited 2015-06-17 05:46
    You should be able to find source code for itoa() with Google.
  • idbruceidbruce Posts: 6,197
    edited 2015-06-17 05:58
    SimpleIDE installs a file named itoa.c. Perform a SimpleIDE folder search for this file. I have not verified whether it works or not,
  • Dave HeinDave Hein Posts: 6,347
    edited 2015-06-17 06:19
    Yes, the file itoa.c is in the simple tools library source directory, but it doesn't seem to be in the library. This may have been removed from the build in one of the latest updates.
  • idbruceidbruce Posts: 6,197
    edited 2015-06-17 06:56
    From comment in simpletools.h
     * @version
     * 0.98 fpucog floating point coprocessor no longer self-starts by default.  
     * All floating point functionality is still supported, processing just happens in
     * the same cog.  i2c_out and i2c_in char regAddr parameter changed to int memAddr. 
     * itoa removed, use sprint(charArray, "%d", intVal) to make int to ASCII 
     * conversions.  st_msTicks and st_usTicks global variables are pre-initialized to the 
     * number of system clock ticks in a millisecond and microsecond for convenience in
     * library development.  Variables named us and ms are initialized to the same values 
     * for user applications.  Function endianSwap added to simplify communication with 
     * devices that send/receive byte data in big endian format.
    
    * itoa removed, use sprint(charArray, "%d", intVal) to make int to ASCII
  • ersmithersmith Posts: 6,053
    edited 2015-06-17 06:59
    Just in case somebody needs it, here is an implementation of itoa (based on the printf code in the latest proplib):
    //
    // Simple implementation of itoa
    // Written by Eric R. Smith and placed in the public domain
    //
    
    //
    // convert an unsigned 32 bit number to ASCII in an an arbitrary base
    // "buf" is the output buffer, which must be big enough to
    // hold it
    //
    
    //
    // reverse a string in-place
    //
    static void _strrev(char *str)
    {
        char *end;
        int c;
    
        for (end = str; *end; end++) ;
        --end;
        while (end > str) {
            c = *str;
            *str++ = *end;
            *end-- = c;
        }
    }
    
    char *
    itoa( int value, char *buf, int base )
    {
        int digits = 0;
        int c;
        unsigned int x;
        char *ret = buf;
        
        if (base == 10 && value < 0) {
            *buf++ = '-';
            x = -value;
        } else {
            x = value;
        }
        do {
            c = x % base;
            x = x / base;
            if (c < 10) c += '0';
            else c = (c - 10) + 'a';
            buf[digits++] = c;
        } while (x > 0);
        buf[digits] = 0;
        _strrev(buf);
        return ret;
    }
    
Sign In or Register to comment.