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

__has_feature may not be accurate #168

Open
tusooa opened this issue Dec 25, 2020 · 5 comments
Open

__has_feature may not be accurate #168

tusooa opened this issue Dec 25, 2020 · 5 comments

Comments

@tusooa
Copy link
Contributor

tusooa commented Dec 25, 2020

For example, Qt will define this macro even if it was not defined.

/usr/include/qt5/QtCore/qcompilerdetection.h:516:#ifndef __has_feature
/usr/include/qt5/QtCore/qcompilerdetection.h:517:#  define __has_feature(x)             0
/usr/include/qt5/QtCore/qcompilerdetection.h-518-#endif

And looks like gcc version 9.3.0 (Gentoo 9.3.0-r1 p3) does not have __has_feature pre-defined.
So if immer headers are included after Qt headers, immer will deem that there is no exception supported, even if I use -fexceptions.

I guess we should at least allow user to always use exceptions (which is important for things like lager::lenses::at because it uses exception to fill in the optional).

@arximboldi
Copy link
Owner

@chuim, what do you think the best solution is here?

@chuim
Copy link
Contributor

chuim commented Dec 26, 2020

Thanks for looping me in. I have no experience on cross compiler support so I have no suggestion to propose. I can try to research a solution once I'm back from the holidays, early next year.

@arximboldi
Copy link
Owner

Cool, thanks!

@chuim
Copy link
Contributor

chuim commented Jan 9, 2021

GCC defines the __cpp_exceptions symbol if exceptions are enabled [1, 2]. I don't have a GCC setup I work with so I'd rather ask someone else to try updating the exception detection code in immer/config.hpp to also check for it.

Also, that snippet of code from Qt seems odd as it decides to override that macro with an always-false implementation what might mislead decisions from other macros in the code.

@arximboldi
Copy link
Owner

Hi @chuim, Thanks for investigating the issue!

Regarding the GCC setup, if you use the nix-shell as advised in the project README it is super easy to get one without polluting your environment. If you are on a Linux the default setup will use a GCC, on Mac you can try nix-shell --argstr toolchain gnu-9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants