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,084
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,084
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
  • Quincy @ Quincy:
    But yes I would welcome MP4 too or even 2+3 remaster/HD to hold us over untill MP4
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    Switch 2 Switched at birth
  • Quincy @ Quincy:
    I check brew almost daily (alongside tinfoil sorted on release date) for new games (and cry because of the amount of shovelware and hentai getting released), am unaware of the 2u site
  • Psionic Roshambo @ Psionic Roshambo:
    Super Switch
  • Quincy @ Quincy:
    HUB
  • Quincy @ Quincy:
    And the switch 3 Router
  • Quincy @ Quincy:
    (every one of those fitting after network-, and all play part in the OSI networking layer model)
  • BigOnYa @ BigOnYa:
    Google switch nsp and you will see,it, that site
  • Quincy @ Quincy:
    Aww how cool that site is Nintendo switch to me :D
    +1
  • Quincy @ Quincy:
    (de-URLing the URL 🤣)
  • Psionic Roshambo @ Psionic Roshambo:
    Switch 2 U
  • Quincy @ Quincy:
    (or do we call them URIs now?)
  • Quincy @ Quincy:
    Yes to me, that's what I said as well 🙃😋
  • Psionic Roshambo @ Psionic Roshambo:
    Switch 2 Side Switching
  • Quincy @ Quincy:
    Swiitch
  • Quincy @ Quincy:
    Oh lord, I actually can see Nintendo pulling that one, II for 2 and also a homage to the Wii
  • Psionic Roshambo @ Psionic Roshambo:
    Super Crown Bowser edition Switch lol
  • Psionic Roshambo @ Psionic Roshambo:
    Analog stick nipples
  • BigOnYa @ BigOnYa:
    Yea i have couple other sites I find Switch titles also and just looked, I don't see it out/leaked yet...(paper mario)
  • Quincy @ Quincy:
    Or even worse; circle pad ball fondlers like on the 3DS
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    I just want a Pokemon Hell Raiser fan game 😭
  • K3Nv2 @ K3Nv2:
    Anyone wanna play with my joydock
  • BigOnYa @ BigOnYa:
    Biomutant looks cool tho, may have to try that
  • Quincy @ Quincy:
    Usually when such a big title leaks the Temp will be the first to report about it (going off of historical reports here, Pokemon SV being the latest one I can recall seeing pop up here)
    Quincy @ Quincy: Usually when such a big title leaks the Temp will be the first to report about it (going off of...