> Sprinkling printf is an efficient way to debug.
I mostly work on threaded code, and print statements are my go to for tracking down weird timing issues. Things behave much more differently when attaching a debugger, and adding good logs makes a ton of sense long term anyway, so yeah, print statements are absolutely a great approach to debugging.
A lot of them are true, but several aren't. I guess that's the thing about lists...
> I mostly work on threaded code, and print statements are my go to for tracking down weird timing issues.
I have found printf to subtly alter timing in threaded programs. Either masking issues or introducing them.
Anecdotally, I remember some programs being reported as working only with a printf present and bombing when removed.
Some embedded envs I've worked in there isn't a argc/argv/envp.
In the Unix envs I've worked in it also takes envp. I think I've use that 3 times in the roughly 25 years I mostly wrote c.
I would think you are generally using _start rather than main in embedded systems. But in embedded systems portability is generally out the window so it makes sense that some _start's call main without arguments.
> In the Unix envs I've worked in it also takes envp. I think I've use that 3 times in the roughly 25 years I mostly wrote c.
I have never tried to use envp and had it fail, but for maximally portable code you should use getenv() or if on posix you can use the environ variable.
> 54. 'main' takes two arguments, argc and argv.
Is this a myth because you are supposed to think of them as one argument?
Or because of non-standard extension that includes envp?
Or because of some other nitpick?
I feel I have a pretty solid understanding of how processes are started for C and I think the statement is true.