C programming: How can I get snprintf to work?

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,074
Country
I'm integrating bits of GodMode9 into my custom A9LH payload. One of the parts I need uses the C function snprintf. When I compile GodMode9, this works fine. But when I compile my own software I get a warning about an implicit declaration, and then the following error at the end of the build process:

Code:
/opt/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/libsysbase.a(sbrk.o): In function `_sbrk_r':
(.text+0x6c): undefined reference to `__end__'
collect2: error: ld returned 1 exit status
make[1]: *** [build/payload_stage2.elf] Error 1
make: *** [stage2] Error 2

If I comment out the line with snprintf, it compiles fine. I have included stdio.h in the .c file which uses this function but it hasn't made any difference. I then checked the makefile and found that it was set to c11, so I changed it to c99 but this also made no difference. I then noticed that there are some differences between the C flags in the makefiles for GodMode9 and my own programme:

  • GodMode9 has the following flags which mine does not: -g -Wpedantic -Wcast-align -pedantic -march=armv5te -mtune=arm946e-s -fomit-frame-pointer
  • My software has the following flags which GodMode9 does not: -MMD -MP -mcpu=arm946e-s -fno-builtin -Wno-main

Does anybody know if any of these flags are responsible for me not being able to use snprintf and if so, how can I get around this?

Thanks in advance!
 

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,074
Country
@JoostinOnline
Thanks for your reply. The calls to snprintf() are quite deeply embedded within other functions so it's hard to post a snippet. However, in the end the solution was to set the CFLAGS in the makefile of 3DSafe to be the same as those in GodMode9 and to include <stdio.h>. It builds and works now :)
 
  • Like
Reactions: JoostinOnline

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    SylverReZ @ SylverReZ: https://www.youtube.com/watch?v=uLN9qrJ8ESs