cancel
Showing results for 
Search instead for 
Did you mean: 

stdio crashes my program, or makes it hang before main

michaelmccartyeng
Associate II
Posted on June 27, 2013 at 02:58

if I have #include <stdio.h> then build and debug the debugger just kind of hangs and is always in the breakpoint state, I hit run but then it just stops instantly. Using Keil. If I remove that include and all references to printf it works fine. 

Any ideas 

@clive, you dont have to answer my question but I was reading a really old ''ASMTUT00.TXT'' file I had printed out that explains assembly ( I read it years ago ) in it the author made references to a ''Clive'' in a section about flags, that was not you right ? 
4 REPLIES 4
Posted on June 27, 2013 at 03:21

With Keil you'll have to see how the output is hosted, by default it's going to generate an SWI to implement some output/os functions, which will either trap the debugger, or Hard Fault. Watch also MicroLIB.

You'd want to fish around the retarget.c/serial.c implementations under the arm\boards directories.

#include <
stdio.h
>
#include <
rt_misc.h
>
#pragma import(__use_no_semihosting_swi)

I guess it could be me, would need to have more context, I've been coding in assembler since the early 1980's and have quite a history with 6502 and x86, my brother had Atari's (68K) and Archimedes (Acorn ARM)
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
michaelmccartyeng
Associate II
Posted on June 27, 2013 at 04:14

http://www.madchat.fr/coding/asm/adamtutorial/Asmtut03.txt

search for ''clive''. 

Posted on June 27, 2013 at 04:44

No, not me.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
michaelmccartyeng
Associate II
Posted on June 27, 2013 at 05:05

so we are not mysteriously linked through space, time and archaic asm tutorials, darn. 

Oh well i'll stop being creepy. 

About the stdio I added the lines in you recommended and got another err about system_exit defined or something. Oh well I dont want to have extra wrenches in my works, printf is overrated. I wasnt even using it for anything, and I know that issue has plagued me for a long time and I never knew what it was. 

But if your in keil and you hit debug then it seems to hit a bp instantly and you can never run and it never gets to main, look to your includes of things like stdio. 

Thanks for the help