Open ojwb opened 1 month ago
This seems a bit of a can of worms, mostly because some (most?) target languages don't support long double
or a suitable type to map it to (e.g. if a target language has an arbitrary precision type that would probably be a reasonable type to map it to).
In cases involving suffixed long double
literals (e.g. 4.0l
) I think this is essentially a regression I introduced in 7ba44dc62de77c23ed67ce4578e1042f7f4e292d when I fixed type handling not to treat float
and long double
literals as double
literals. That's needed for C++ auto
and decltype
to work correctly, so reverting isn't the answer.
We currently have no typemaps for long double
except for a Python doctype
one, and adding them for all current target languages seems a bit of an involved project.
We could perhaps add long double
to each double
typemap more easily (and for languages without anything better to map long double
to, that seems the best we can do), though we also need to ensure the typemap code handles the type not being exactly double
.
As a workaround, the last part can be done already by the user via:
%apply double { long double };
This doesn't seem to work well in most target languages currently. Here's a testcase patch to demonstrate this:
Spotted while looking at removing the code to strip
l
suffixes from these constants. This change doesn't seem to make the situation worse, but I'm hesitant to merge it without test coverage: