Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion source/compatibility.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3720,7 +3720,9 @@
The C headers \libheader{complex.h} and
\libheader{tgmath.h} do not contain any of the content from
the C standard library and instead merely include other headers from the \Cpp{}
standard library.
standard library. Whereas the \libheader{tgmath.h} macros can be suppressed in
C by, for example, using parentheses around the macro name, the \Cpp{} overload
sets cannot be bypassed in this manner; casts may be used instead.
Comment on lines +3723 to +3725
Copy link
Member

Choose a reason for hiding this comment

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

This seems tutorial-like to be honest. The wording is clear that the tgmath.h macros don't exist in C++, and that's all that really needs to be said about compatibility differences.

Even if we want to have this new sentence, it seems like something that goes into a \begin{note} context.

I'm also not sure what you mean by "casts may be used instead". Are you casting the function itself to double(&)(double)? That isn't valid because of addressability restrictions. You could cast all the function arguments like sqrt((double)x), but that's possible in both languages, so it doesn't seem like it needs to be called out in [diff].

Copy link
Member

Choose a reason for hiding this comment

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

I agree with the statement about casts; @hubert-reinterpretcast , please tell us what you mean by those "casts".

I do want to point out that Annex C is tutorial-like in nature (nothing new in that Annex, hopefully), so I'm not objecting to adding a clarifying sentence. However, I wonder whether an actual code example would convey the consequences more clearly.

#include <tgmath.h>

double x = (sqrt)(2.0f);   // calls sqrt(double) in C, but sqrt(float) in C++

Maybe just striking "casts may be used instead" is a way forward?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please tell us what you mean by those "casts".

Yes, I meant casting the arguments to match the C non-macro function signature.


\rSec2[diff.mods.to.definitions]{Modifications to definitions}

Expand Down