Topic: linkage of atexit


Author: kanze@gabi-soft.fr
Date: Fri, 29 Oct 2004 17:21:01 GMT
Raw View
In    18.3, the standard specifies two possible signatures for atexit.  Is
it the intent that an implementation must provide both?

  - If yes, why isn't this specified explicitly, as it is, for example,
    in the functions in    21.4?

  - If no, then presumably the implementation is required to provide one
    or the other -- this is simply an explicit example of    17.4.2.2/2.
    In this case, however, how can one possibly use the function in
    portable code, since the parameter types of the two functions are
    different?

--
James Kanze           GABI Software         http://www.gabi-soft.fr
Conseils en informatique orient   e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S   mard, 78210 St.-Cyr-l'   cole, France, +33 (0)1 30 23 00 34

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: AlbertoBarbati@libero.it (Alberto Barbati)
Date: Sun, 31 Oct 2004 08:11:46 GMT
Raw View
kanze@gabi-soft.fr wrote:
> In =A718.3, the standard specifies two possible signatures for atexit. =
 Is
> it the intent that an implementation must provide both?
>=20
>   - If yes, why isn't this specified explicitly, as it is, for example,
>     in the functions in =A721.4?
>=20
>   - If no, then presumably the implementation is required to provide on=
e
>     or the other -- this is simply an explicit example of =A717.4.2.2/2.
>     In this case, however, how can one possibly use the function in
>     portable code, since the parameter types of the two functions are
>     different?
>=20

The functions in =A721.4 are a bit different from atexit, because they=20
don't involve linkage specifications. More relevant examples are=20
functions bsearch and qsort in =A725.4 where in fact the signatures with=20
both "C" and "C++" linkage are explicitly specified. I guess the=20
difference is due to the fact that the interpretation of=20
pointer-to-function arguments are affected by the linkage specification,=20
so I believe atexit should also provide both signature and =A718.3 should=
=20
specify that explicitly.

That makes me think, however. Instead of requiring two signatures like:

   extern "C" int atexit(void (*f)(void))
   extern "C++" int atexit(void (*f)(void))

an alternative set if signatures could have been:

   extern "C" typedef void (*atexit_handler_c)();
   extern "C++" typedef void (*atexit_handler_cpp)();

   int atexit(atexit_handler_c);
   int atexit(atexit_handler_cpp);

I guess the former choice has been followed for better compatibility=20
with the C library, but the latter choice would have been more=20
consistent with the approach followed in =A721.4.

Just my =800.02

Alberto

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: kuyper@wizard.net (James Kuyper)
Date: Mon, 1 Nov 2004 07:30:32 GMT
Raw View
AlbertoBarbati@libero.it (Alberto Barbati) wrote in message news:<YSJgd.8310$Es2.168971@twister2.libero.it>...
> In    18.3, the standard specifies two possible signatures for atexit.  Is
> it the intent that an implementation must provide both?

I believe it is; the intent being to allow registration of functions
with either "C" or "C++" language linkage.

>   - If yes, why isn't this specified explicitly, as it is, for example,
>     in the functions in    21.4?

Good question.

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]