Go Down

Topic: asprintf replacement for arduino (Read 1 time) previous topic - next topic


I am trying to use "asprintf" in an arduino sketch. Although this function is in stdc but the compiler still gives me this error:

'asprintf' was not declared in this scope
here is my code snippet:
asprintf(&cmdBuffer, "move:%s", moves_list->begin);

The function asprintf() is analog of sprintf(3) except that it allocate a string large enough to hold the output including the terminating null byte, and return a pointer to it via the first argument.

Can any one tell if there is a supported function with the same functionality or how I can write a replacement function. I am trying to post some code over to arduino and to maintain support for updates I cant really remove the asprintf function all together.

Any inputs would be helpful


Well, I did a text sdearch in my arduino code home, and found the HTML file that describes "libiberty", wherethe function is described. I can also see that the object file is there, but there is no ".h" defining the prototype. Defining one myself works for compiling but fails on link. So - and this is where I gave up - one needs to specfically ask to include the lib/libiberty.a file in the link.

On a completly different note: The microcontroller chip has limited RAM. Doing things with malloc etc works, but people who do so usually very quickly exhaust memory. And being a microcontroller, there is no pretty "program memory exhausted" message as the program exits, as there is nothing to exit to; It just keeps on running, looping, crashing, hanging until the reset button is pressed.

Handle your own buffers. :)

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131