Why is argc an 'int' (rather than an 'unsigned int')?

Because C is old, and it was designed that way from the start. It's too late to change it now.


The fact that the original C language was such that by default any variable or argument was defined as type int, is probably another factor. In other words you could have:

  main(argc, char* argv[]);  /* see remark below... */

rather than

int main(int argc, char *argv[]);

Edit: effectively, as Aaron reminded us, the very original syntax would have been something like

  main(argc, argv) char **argv {... } 

Since the "prototypes" were only introduced later. That came roughly after everyone had logged a minimum of at least 10 hours chasing subtle (and not so subtle) type-related bugs


A few reasons:

  • because it doesn't matter
  • because C did not originally have the unsigned keyword or unsigned integer types
  • because C did not originally check parameter types and did not even have prototypes.
    As a result, it was common practice to not even declare int types, as this was the default.
  • because int was, in a sense, more important back then. Everything was an int. C evolved in part from a language that did not even have types. Every single varable was a word, which is what int originally was used for.

UPDATE: Jason S asked for sources. I think you can dig all of this (except for "it doesn't matter") out of a paper by dmr which is on line: The Development of the C Language. You may need to look up the earlier languages BCPL and B in the usual places.