C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

linkage of atexit

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
kanze@gabi-soft.fr
Guest





PostPosted: Fri Oct 29, 2004 5:21 pm    Post subject: linkage of atexit Reply with 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?

--
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





PostPosted: Sun Oct 31, 2004 8:11 am    Post subject: Re: linkage of atexit Reply with quote



[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





PostPosted: Mon Nov 01, 2004 7:30 am    Post subject: Re: linkage of atexit Reply with quote



[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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.