Search code examples
clinuxbashgcccc

getenv("cc") is returning NULL , why?


I am learning C and came across cc in the bash shell i.e. whenever I make my source files I see this command.

Hence started to understand it,started with gcc --help but couldn't find cc option in the help. So started surfing the net, and came across this post. In the second answer it says cc is an environment variable and often points to /usr/bin/gcc on Linux systems.

I am using Linux distro and when I print return value from getenv("cc"), I am getting NULL. Why is this happening?


Solution

  • cc is usually not an environment variable. There is commonly a symbolic link /usr/bin/cc which points at gcc.