This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Can argv be NULL in C?


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 (齐尧)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]