New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cstdlib.syn, csignal.syn] Introduce exposition-only function types with C and C++ language linkage to improve the presentation of C library functions that take callbacks. #1049
Conversation
@@ -3039,12 +3039,18 @@ | |||
#define MB_CUR_MAX @\seebelow@ | |||
|
|||
namespace std { | |||
// Exposion-only function type aliases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed!
@@ -3039,12 +3039,18 @@ | |||
#define MB_CUR_MAX @\seebelow@ | |||
|
|||
namespace std { | |||
// Exposition-only function type aliases | |||
extern "C" using c_exit_t = void(); // \expos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[objects.within.classes]/2 only defines what the "// exposition only" comment means for private members of classes. This isn't the only place where we would be using it for something else, but it might be a good idea to move the definition of "exposition only" to somewhere more general, and just refer to it from [objects.within.classes]/2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new subclause to define exposition-only types.
@@ -3039,12 +3039,18 @@ | |||
#define MB_CUR_MAX @\seebelow@ | |||
|
|||
namespace std { | |||
// Exposition-only function type aliases | |||
extern "C" using c_exit_t = void(); // \expos | |||
extern "C++" using cxx_exit_t = void(); // \expos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only use of "cxx" to refer to C++ in the standard; we use "cpp" in the few places where this comes up. Perhaps we could just omit the cxx_
prefix and maybe also the extern "C++"
?
I would also avoid an _t
name, since that makes it look more like this is a name exposed by the library. Maybe even avoiding a real identifier entirely, and/or using an alternative typographical convention, would help to emphasize that this is not an exposed name:
using
atexit-handler
= void(); //
exposition only
extern "C" using
c-atexit-handler
= void(); //
exposition only
int atexit(
atexit-handler
* func);
int atexit(
c-atexit-handler
* func);
int at_quick_exit(
atexit-handler
* func);
int at_quick_exit(
c-atexit-handler
* func);
... although I note that none of our existing exposition-only names use such a typographical convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed cxx_
and renamed the typedefs to _fn
.
I like the placeholder style, but take note that we we will need to refer to that name in the itemdescls as well, which are quite far way (see updated PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I retained the extern "C++"
, because it makes the columns line up nicely :-S
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented the placeholder types.
extern "C" int at_quick_exit(void (*func)()); | ||
extern "C++" int at_quick_exit(void (*func)()); | ||
int atexit(c_exit_t* fuc); | ||
int atexit(cxx_exit_t* fuc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you accidentally lost an 'n' here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
…ith C and C++ language linkage to improve the presentation of C library functions that take callbacks. This change improves correctness, since we never meant to specify the language linkage of the function names, but only of the callback parameter type. Fixes cplusplus#1002.
This change improves correctness, since we never meant to specify the language linkage of the function names, but only of the callback parameter type.
Fixes #1002.