understanding C namespaces

C has four different name spaces for identifiers:

  • Label names (the goto type).
  • Tags (names of structures, unions and enumerations).
  • Members of structures and unions (these have a separate namespace per structure/union).
  • All other identifiers (function names, object names, type(def) names, enumeration constants, etc).

See also C99 6.2.3.

So your two question can be answered as:

  1. Yes, function names and typedef names share the same name space.
  2. No conflict, because the compiler will use scope rules (for function or object names). The identifier in main is said to shadow the global function name, something your compiler will warn you about if you set the warning levels high enough.

Leave a Comment