Beautified That For You
-
@dkf
So is it different for programs that don't have amain()
function? I seem to remember seeing code (Obfuscated C Contest entries, maybe?) that was basically a series ofprintf()
calls that would compile and run just fine without havingmain()
.
It could be that my rememberer is fritzy.
-
@djls45 said in Beautified That For You:
It could be that my rememberer is fritzy.
The programs shouldn't link without a
main()
, and that function has to be in the object files that make up the main program or some linkers throw a wobbly. (No, you can't safely put it in a DLL.)The
main()
could be an empty function. :p
-
@dkf wars!
Embedded can be different. If the memory map is a bit weird, you may want to tell the linker there's no main(), set up the vector table with your own entry point, and initialize .bss and .data yourself.
-
@clatter said in Beautified That For You:
Embedded can be different.
Well, yes, but then you're not doing a standard C program and can follow any rules you want.
-
I much prefer
#include "stdio.h" int main(int argc,char**argv){ char const*str="Hello, world!"; printf("%s\n",str); return 0;}
Or even:
#include "my.h" int main(int argc,char**argv){ char cz*str="Hello, world!"; pf("%s\n",str); rrn 0;}
-