# Forum: ARM programming with GCC/GNU tools sprintf

Rate this post
 0 ▲ useful ▼ not useful
I am attempting to use sprintf without success.

in main i have:

char str[80];

sprintf(str, "sprintf test - Hex Number %02X - Decimal Number %d",
127, 0x0a);

After this line of code is run I would expect str to conatin:
"sprintf test - Hex Number 7F - Decimal Number 10" without the quotes
ocourse.

This code does not compile. I never get to run it. Instead I get this
build error:

C:\msys\1.0\home\yagarto\newlib-build\arm-elf\newlib\libc\sys\arm/../../
../../../../newlib-1.14.0/newlib/libc/sys/arm/syscalls.c
undefined reference to end'

This directory does not even exist on my hard drive!

Rate this post
 0 ▲ useful ▼ not useful
somewhere in this
I believed Clifford mentioned it sometime ago relating to syscalls, and

Harold Ritter wrote:
> I am attempting to use sprintf without success.
>
> in main i have:
>
> char str[80];
>
>
>   sprintf(str, "sprintf test - Hex Number %02X - Decimal Number %d",
> 127, 0x0a);
>
> After this line of code is run I would expect str to conatin:
>   "sprintf test - Hex Number 7F - Decimal Number 10" without the quotes
> ocourse.
>
> This code does not compile. I never get to run it. Instead I get this
> build error:
>
> C:\msys\1.0\home\yagarto\newlib-build\arm-elf\newlib\libc\sys\arm/../../
../../../../newlib-1.14.0/newlib/libc/sys/arm/syscalls.c
> undefined reference to end'
>
> This directory does not even exist on my hard drive!

Rate this post
 0 ▲ useful ▼ not useful
Mhel,

Thank you so much! Indeed the answer was there and here it is quoted
directly from Sparkfun. IT WORKS!

***********************************************************
The end is close.
The end in this case is a symbol that points to the first free word in
RAM after all global variables has been placed there. Some codelibraries
use the symbol _end and some use the symbol end (without the
underscore). It is usually defined in the linker script, in you case

At the end, after the the definition of the symbol _end, add the line
PROVIDE(end = .);
This means: let the symbol 'end' point to the current position unless it
has been given a differnt value somewhere else.
[Jim] Perhaps this should standard in the linker scripts.
Code:

_end = .;
PROVIDE(end = .);

So actually end is the beginning of the heap.

Regards,
Magnus
*************************************************************

Thanks again Mhel and a special thanks to Magnus on sparkfun!

Harold

Mhel Marcelo wrote:
> somewhere in this
>
> I believed Clifford mentioned it sometime ago relating to syscalls, and
> pointed to the same link.
>
> Harold Ritter wrote:
>> I am attempting to use sprintf without success.
>>
>> in main i have:
>>
>> char str[80];
>>
>>
>>   sprintf(str, "sprintf test - Hex Number %02X - Decimal Number %d",
>> 127, 0x0a);
>>
>> After this line of code is run I would expect str to conatin:
>>   "sprintf test - Hex Number 7F - Decimal Number 10" without the quotes
>> ocourse.
>>
>> This code does not compile. I never get to run it. Instead I get this
>> build error:
>>
>> C:\msys\1.0\home\yagarto\newlib-build\arm-elf\newlib\libc\sys\arm/../../
../../../../newlib-1.14.0/newlib/libc/sys/arm/syscalls.c
>> undefined reference to end'
>>
>> This directory does not even exist on my hard drive!`

• Post long source code as attachment, not in the text

### Formatting options

• [c]C code[/c]
• [avrasm]AVR assembler code[/avrasm]
• [code]code in other languages, ASCII drawings[/code]
• $formula (LaTeX syntax)$
 Name: E-mail address (not visible): Subject: Searching for similar topics... Attachment: Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one. Text: