TITLE: identifier name collisions with standard functions... (Private e-mail, 14 July 97) JAMSHID: jamshid@ses.com Remember that Standard C reserves many identifier names. You should not use them when naming variables or functions you define. For example, the following code fails to compile under Visual C++ 5: char *fileErrorString( ParmStruct ) { int errno = -IntegerParm(0); // ERROR if ( ( errno>=0 ) && ( errno <= sys_nerr ) ) return estrdup(sys_errlist[errno]); else return estrdup("invalid error code"); } "errno" is defined by the Standard C header and is required to *act* as if it is a variable defined like: extern int errno; But, compilers are free to actually implement "errno" as a macro which expands to a different variable name or even to a function call. When using certain compiler options, that's exactly what VC++ does: /* */ #if (defined(_MT) || defined(_DLL)) extern int* _errno(void); #define errno (*_errno()) #else extern int errno; #endif As you can imagine, the original code causes a strange compiler error because the local variable name "errno" gets replaced with "(*_errno())". Moral: Don't use Standard C function or variable names when defining your own functions and variables, even if it happens to work on some compilers and with certain compiler options. Also, if you need to use a function or variable defined by the C library, #include the Standard C header which defines it instead of declaring it yourself (eg, don't assume that the C library defines "errno" as a plain global int). PS: I believe Standard C++ relaxed the rules related to reserved identfier names a bit to allow developers to overload Standard function names for their own types or use Standard function names when naming their own member functions. For example, a developer can define a class and with a "raise" member function: class Foo { public: void raise(); }; This would give a compiler error if were allowed to define raise as a macro: #define raise(x) __raise(__pid, x) /* okay for C, not okay for C++ */ So, a C++ header must use a mechanism other than preprocessor macros: inline raise(int sig) { __raise(__pid, sig); }