2

I am on exercise 2 of "Learn C the Hard Way. One of the extra credit challenges is:

Read man cc to find out more information on what the flags -Wall and -g do.

I am on OSX and used man cc to open the manual page but it doesn't have any info about -Wall or -g. However, I logged into a machine running Ubuntu and found a much larger manual page for cc that did include the information.

Why are the manual pages for OSX (Darwin?) and Ubuntu different? I obviously don't know anything about this stuff but I would've assumed that the manual pages would come packaged with the software and thus be the same no matter where the software was installed.

sixty4bit
  • 7,422
  • 7
  • 33
  • 57
  • 1
    You can install gcc over homebrew `brew install gcc` and access its manpages instead. e.g. `man gcc-5`. – a3f Feb 05 '16 at 05:33
  • It works for me with current versions of OS X and Xcode - `man cc` takes you to the man page for clang, and this includes info on `-W` and `-g`. – Paul R Feb 05 '16 at 09:23

2 Answers2

3

It's likely that your OS X installation is using a compiler named clang and your Linux installation is using a compiler named gcc.

Therefore the man pages on OS X are probably written by the clang team and the man pages on your Linux installation are probably written by the gcc team.

These two compilers generally accept the same command line arguments though.

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
  • Thank you. I had completely overlooked that `man cc` brought me to a manpage for `clang` on my OSX machine and `gcc` on Ubuntu. I was used to `man` taking a program name as its argument but it seems that `cc` points to different C compilers. Is that right? when I run `ls -l /usr/bin/cc` on OSX I see a symlink to `clang` (`/usr/bin/cc -> clang`). So what does `cc` stand for? – sixty4bit Feb 05 '16 at 15:58
  • `/usr/bin/cc` is often a link to the vendor supplied c compiler. – Bill Lynch Feb 05 '16 at 16:10
3

Compilers *nix manual pages now only gives you the very basics. There is too many controls in a compiler chain to give you all of them in manual pages. Even --help option will not give you all controls. clang --help (on OSX) gives you about 350 lines, but the single list of clang warnings controls are about 450... It is difficult to count the number of options a compiler offers you, but probably thousands...

For such a tool, I encourage you to have a look at the online manuals.

Why different? Because compiler chains are dependent on Architecture/OS/ABI/Assembly/Linker, etc. So the same compiler (gcc for example) can behave differently on different platform; manuals should be different. Anyway, -Wall and -g are very common and basic, I am surprised that Wall don't appear in OSX manual...

Jean-Baptiste Yunès
  • 34,548
  • 4
  • 48
  • 69