Pages: [1]   Go Down
Author Topic: asprintf replacement for arduino  (Read 647 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 32
Posts: 1204
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley
Logged

Pages: [1]   Go Up
Jump to: