sprintf

OP #1173471
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!
somewhere in this
http://forum.sparkfun.com/viewtopic.php?t=5390&postdays=0&postorder=asc&start=15&sid=01422ee0aa76eee5510ade03e165d0e3
has the answer.
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!
OP
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

demo_at91sam7_blink_flash.cmd

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
> 
http://forum.sparkfun.com/viewtopic.php?t=5390&postdays=0&postorder=asc&start=15&sid=01422ee0aa76eee5510ade03e165d0e3
> has the answer.
> 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!

Reply

A question of your own? This thread is over 18 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.