Have not used PropGCC for awhile?
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
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:/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
Instead of itoa you could use sprintf:
sprintf(second, "%d", first);
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
Ray
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).
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. } }
* @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.
// // 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; }