Topic: Names reserved by standard headers (eg, errno)


Author: tony@online.tmx.com.au (Tony Cook)
Date: 1997/07/16
Raw View
Jamshid Afshar (jamshid@io.com) wrote:
: Is the compiler allowed to define "errno" as a macro which expands to
: a function call (eg, (*_errno)()) in C++?  I know it can in Standard
: C, making the following code illegal:

See section 17.3.1.2, [lib.headers], paragraph 5:

5 Names which are defined as macros in C shall be defined as macros in
  the C++ Standard library, even if license is granted in C for imple-
  mentation as functions.  [Note:  the names defined as macros in C
  include the following:  assert, errno, offsetof, setjmp, va_arg,
  va_end, and va_start.   --end note]


--
        Tony Cook - tony@online.tmx.com.au <= testing .procmailrc
                    100237.3425@compuserve.com
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Jamshid Afshar <jamshid@io.com>
Date: 1997/07/15
Raw View
Is the compiler allowed to define "errno" as a macro which expands to
a function call (eg, (*_errno)()) in C++?  I know it can in Standard
C, making the following code illegal:

   int foo(void) {
      int errno = 5;  /* C error: using name defined in standard library */
      /*...*/
   }

but I don't see anything in 17.3.3.1 Reserved Names that restricts
developers from using the name "errno" as a local variable name.
17.3.3.1.3 only seems to restrict developers from using it as a global
name: "each name declared as an object with external linkage in a
header is reserved to the implementation to designate that library
object with external linkage."

PS: am I correct in assuming that while C allowed the implementation
to define Standard functions as macros, Standard C++ does not,
allowing developers to overload Standard function names (eg, define a
"pow" function for their BigInt type) or to use Standard function
names as member function names (eg, a "raise" member function on their
Process class)?

Thanks,
Jamshid Afshar
jamshid@io.com
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]