Skip to content
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

Merged
merged 1 commit into from Nov 16, 2016

Conversation

tkoeppe
Copy link
Contributor

@tkoeppe tkoeppe commented Nov 15, 2016

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.

@@ -3039,12 +3039,18 @@
#define MB_CUR_MAX @\seebelow@

namespace std {
// Exposion-only function type aliases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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:

usingatexit-handler= void(); //exposition only
extern "C" usingc-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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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);
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Nov 16, 2016

image

image

…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.
@zygoloid zygoloid merged commit 9df9501 into cplusplus:master Nov 16, 2016
@tkoeppe tkoeppe deleted the extern_c branch November 16, 2016 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants