 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
kanze@gabi-soft.fr Guest
|
Posted: Fri Oct 29, 2004 5:21 pm Post subject: linkage of atexit |
|
|
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 ]
|
|
| Back to top |
|
 |
Alberto Barbati Guest
|
Posted: Sun Oct 31, 2004 8:11 am Post subject: Re: linkage of atexit |
|
|
[email]kanze (AT) gabi-soft (DOT) fr[/email] wrote:
| Quote: | 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?
|
The functions in §21.4 are a bit different from atexit, because they
don't involve linkage specifications. More relevant examples are
functions bsearch and qsort in §25.4 where in fact the signatures with
both "C" and "C++" linkage are explicitly specified. I guess the
difference is due to the fact that the interpretation of
pointer-to-function arguments are affected by the linkage specification,
so I believe atexit should also provide both signature and §18.3 should
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
with the C library, but the latter choice would have been more
consistent with the approach followed in §21.4.
Just my €0.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 ]
|
|
| Back to top |
|
 |
James Kuyper Guest
|
Posted: Mon Nov 01, 2004 7:30 am Post subject: Re: linkage of atexit |
|
|
[email]AlbertoBarbati (AT) libero (DOT) it[/email] (Alberto Barbati) wrote in message news:<YSJgd.8310$Es2.168971 (AT) twister2 (DOT) libero.it>...
| Quote: | 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.
| Quote: | - 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 ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|