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

Consistent (and conventional) spelling of struct tm #4338

Closed
AlisdairM opened this issue Nov 11, 2020 · 5 comments · Fixed by #4483
Closed

Consistent (and conventional) spelling of struct tm #4338

AlisdairM opened this issue Nov 11, 2020 · 5 comments · Fixed by #4483
Assignees

Comments

@AlisdairM
Copy link
Contributor

AlisdairM commented Nov 11, 2020

Conventionally, when C++ declares or defines a struct type, such as struct timespec;, it refers to that type by name without the struct tag when used.

However, struct tm appears to be something of a special case. As this type is supplied by the C library, and appears in mostly C specified APIs, the struct tag (required by C compilers) has been preserved in much of our wording and library synopses. However, the <locale> header is an exception, consistently referring to just tm* in the functions it declares.

We should be consistent in how we reference this type in C++ source, and make an active decision to either follow the C++ convention of not repeating the struct tag on each use, or whether we prefer to follow the C convention of requiring the struct tag in each case.

@AlisdairM
Copy link
Contributor Author

Note that I deliberately used timespec as my counterexample, as it comes from the same header and we follow the C++ conventions in this case, although it has distinctly fewer usages to establish a pattern.

@jensmaurer
Copy link
Member

Note that this approaches "struct stat" territory (although "stat" is POSIX, not C), and we would definitely want the "struct" in front for "stat".

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Nov 11, 2020
@jensmaurer
Copy link
Member

Editorial meeting: Drop "struct" in front of "tm" to avoid (the impression of) accidental introduction of the name in the immediately-enclosing namespace.

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Jan 29, 2021
@jensmaurer
Copy link
Member

We have declarations of "struct tm" in header synopses <cwchar> and <ctime>, showing that "struct tm" is a member of namespace std. That's probably not exactly great, but also likely a LWG-level larger wording issue.

@tkoeppe
Copy link
Contributor

tkoeppe commented Feb 6, 2021

I don't think we spotted this detail when we reviewed P0175. Prior to that, we didn't have the synopses at all and just refered to C, so at this point I would simply consider this something unclear that we never discussed.

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 a pull request may close this issue.

3 participants