Can argv be NULL in C?
Yao Qi
qiyaoltc@gmail.com
Fri Oct 7 16:40:00 GMT 2016
Hi,
Luis has a GDB patch https://sourceware.org/ml/gdb-patches/2016-10/msg00137.html
which checks whether argv is NULL or not, because argv is NULL in
his env (aarch64-elf).
Can argv be NULL in C? In C standard, argc and argv is specified
in "hosted environment", so argv can't be NULL in "hosted environment".
The program start-up is implementation-defined in "freestanding
environment". Then, in practise, is bare-metal a "freestanding
environment"? The bare-metal may still have its C library, like newlib,
so is it a "freestanding environment" or "hosted environment"?
In this particular case, the C code has main function, so it expects
argument passing (argc and argv) from somewhere else, so my
understanding is that it is "hosted environment", and its argv must
be non-NULL.
--
Yao (齐尧)
More information about the Gcc-help
mailing list