Error: 'uncaught_exceptions' is unavailable: introduced in macOS 10.12
up vote
1
down vote
favorite
I'm testing for a problem that surfaced recently during testing under C++17. Here is the source file:
$ cat test.cxx
#if __EXCEPTIONS && __has_feature(cxx_exceptions)
# include <exception>
# define CXX17_EXCEPTIONS 1
#endif
void Foo()
#if defined(CXX17_EXCEPTIONS)
if (std::uncaught_exceptions() == 0)
#endif
int x = 0;
And compiling it using Macports compiler on OS X 10.8 or 10.9:
$ /opt/local/bin/clang++-mp-5.0 -std=gnu++17 test.cxx -c
test.cxx:9:14: error: 'uncaught_exceptions' is unavailable: introduced in macOS 10.12
if (std::uncaught_exceptions() == 0)
^
/opt/local/libexec/llvm-5.0/include/c++/v1/exception:130:63: note:
'uncaught_exceptions' has been explicitly marked unavailable here
_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_e...
^
1 error generated.
/opt/local/bin/clang++-mp-5.0
also experiences the issue. It does not appear to be a one-off problem. 4.0 rejects -std=gnu++17
so I can't test back further.
According to Clang 3.6 Release Notes, I believe I am using the correct test for std::uncaught_exceptions()
:
To reliably test if C++ exceptions are enabled, use __EXCEPTIONS &&
__has_feature(cxx_exceptions), else things won’t work in all versions of Clang in Objective-C++ files.
I probably won't be able to include an Apple specific header file, so I won't be able to test for OS X 10.12. Others have experienced the issue but I have not found a proper solution. For example, this bug report has the same unresolved issue.
Is there a way to work around the issue on Apple platforms that includes standard C++ preprocessor macros and feature testing? If so, what is the method or tests?
$ /opt/local/bin/clang++-mp-6.0 --version
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-6.0/bin
$ /opt/local/bin/clang++-mp-5.0 --version
clang version 5.0.2 (tags/RELEASE_502/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-5.0/bin
macos exception clang c++17 feature-detection
add a comment |
up vote
1
down vote
favorite
I'm testing for a problem that surfaced recently during testing under C++17. Here is the source file:
$ cat test.cxx
#if __EXCEPTIONS && __has_feature(cxx_exceptions)
# include <exception>
# define CXX17_EXCEPTIONS 1
#endif
void Foo()
#if defined(CXX17_EXCEPTIONS)
if (std::uncaught_exceptions() == 0)
#endif
int x = 0;
And compiling it using Macports compiler on OS X 10.8 or 10.9:
$ /opt/local/bin/clang++-mp-5.0 -std=gnu++17 test.cxx -c
test.cxx:9:14: error: 'uncaught_exceptions' is unavailable: introduced in macOS 10.12
if (std::uncaught_exceptions() == 0)
^
/opt/local/libexec/llvm-5.0/include/c++/v1/exception:130:63: note:
'uncaught_exceptions' has been explicitly marked unavailable here
_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_e...
^
1 error generated.
/opt/local/bin/clang++-mp-5.0
also experiences the issue. It does not appear to be a one-off problem. 4.0 rejects -std=gnu++17
so I can't test back further.
According to Clang 3.6 Release Notes, I believe I am using the correct test for std::uncaught_exceptions()
:
To reliably test if C++ exceptions are enabled, use __EXCEPTIONS &&
__has_feature(cxx_exceptions), else things won’t work in all versions of Clang in Objective-C++ files.
I probably won't be able to include an Apple specific header file, so I won't be able to test for OS X 10.12. Others have experienced the issue but I have not found a proper solution. For example, this bug report has the same unresolved issue.
Is there a way to work around the issue on Apple platforms that includes standard C++ preprocessor macros and feature testing? If so, what is the method or tests?
$ /opt/local/bin/clang++-mp-6.0 --version
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-6.0/bin
$ /opt/local/bin/clang++-mp-5.0 --version
clang version 5.0.2 (tags/RELEASE_502/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-5.0/bin
macos exception clang c++17 feature-detection
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm testing for a problem that surfaced recently during testing under C++17. Here is the source file:
$ cat test.cxx
#if __EXCEPTIONS && __has_feature(cxx_exceptions)
# include <exception>
# define CXX17_EXCEPTIONS 1
#endif
void Foo()
#if defined(CXX17_EXCEPTIONS)
if (std::uncaught_exceptions() == 0)
#endif
int x = 0;
And compiling it using Macports compiler on OS X 10.8 or 10.9:
$ /opt/local/bin/clang++-mp-5.0 -std=gnu++17 test.cxx -c
test.cxx:9:14: error: 'uncaught_exceptions' is unavailable: introduced in macOS 10.12
if (std::uncaught_exceptions() == 0)
^
/opt/local/libexec/llvm-5.0/include/c++/v1/exception:130:63: note:
'uncaught_exceptions' has been explicitly marked unavailable here
_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_e...
^
1 error generated.
/opt/local/bin/clang++-mp-5.0
also experiences the issue. It does not appear to be a one-off problem. 4.0 rejects -std=gnu++17
so I can't test back further.
According to Clang 3.6 Release Notes, I believe I am using the correct test for std::uncaught_exceptions()
:
To reliably test if C++ exceptions are enabled, use __EXCEPTIONS &&
__has_feature(cxx_exceptions), else things won’t work in all versions of Clang in Objective-C++ files.
I probably won't be able to include an Apple specific header file, so I won't be able to test for OS X 10.12. Others have experienced the issue but I have not found a proper solution. For example, this bug report has the same unresolved issue.
Is there a way to work around the issue on Apple platforms that includes standard C++ preprocessor macros and feature testing? If so, what is the method or tests?
$ /opt/local/bin/clang++-mp-6.0 --version
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-6.0/bin
$ /opt/local/bin/clang++-mp-5.0 --version
clang version 5.0.2 (tags/RELEASE_502/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-5.0/bin
macos exception clang c++17 feature-detection
I'm testing for a problem that surfaced recently during testing under C++17. Here is the source file:
$ cat test.cxx
#if __EXCEPTIONS && __has_feature(cxx_exceptions)
# include <exception>
# define CXX17_EXCEPTIONS 1
#endif
void Foo()
#if defined(CXX17_EXCEPTIONS)
if (std::uncaught_exceptions() == 0)
#endif
int x = 0;
And compiling it using Macports compiler on OS X 10.8 or 10.9:
$ /opt/local/bin/clang++-mp-5.0 -std=gnu++17 test.cxx -c
test.cxx:9:14: error: 'uncaught_exceptions' is unavailable: introduced in macOS 10.12
if (std::uncaught_exceptions() == 0)
^
/opt/local/libexec/llvm-5.0/include/c++/v1/exception:130:63: note:
'uncaught_exceptions' has been explicitly marked unavailable here
_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_e...
^
1 error generated.
/opt/local/bin/clang++-mp-5.0
also experiences the issue. It does not appear to be a one-off problem. 4.0 rejects -std=gnu++17
so I can't test back further.
According to Clang 3.6 Release Notes, I believe I am using the correct test for std::uncaught_exceptions()
:
To reliably test if C++ exceptions are enabled, use __EXCEPTIONS &&
__has_feature(cxx_exceptions), else things won’t work in all versions of Clang in Objective-C++ files.
I probably won't be able to include an Apple specific header file, so I won't be able to test for OS X 10.12. Others have experienced the issue but I have not found a proper solution. For example, this bug report has the same unresolved issue.
Is there a way to work around the issue on Apple platforms that includes standard C++ preprocessor macros and feature testing? If so, what is the method or tests?
$ /opt/local/bin/clang++-mp-6.0 --version
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-6.0/bin
$ /opt/local/bin/clang++-mp-5.0 --version
clang version 5.0.2 (tags/RELEASE_502/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-5.0/bin
macos exception clang c++17 feature-detection
macos exception clang c++17 feature-detection
asked Nov 11 at 21:44
jww
52.6k38220481
52.6k38220481
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
2
down vote
The problem here is that the runtime library (libc++.dylib
) shipped on Mac OS before 10.12 does not contain a definition for std::uncaught_exceptions()
. If you were to try using it on those platforms, it would result on a linker error. So instead, we're warning you at compile-time that this would fail. This has nothing to do with exceptions being available/unavailable: it's about the specific function not being available.
add a comment |
up vote
1
down vote
__EXCEPTIONS && __has_feature(cxx_exceptions)
tests if exceptions are available. Exceptions are a language feature that has been in C++ since about 1990 (they weren't introduced in C++17!), so unless you explicitly disable exceptions they should always be available.
__cpp_lib_uncaught_exceptions
alone is the correct test.
add a comment |
up vote
0
down vote
I'm not sure if this is the correct way to handle the situation, but it may help others.
$ cat test.cxx
#if __EXCEPTIONS && __has_feature(cxx_exceptions)
# if __cpp_lib_uncaught_exceptions
# include <exception>
# define CXX17_EXCEPTIONS 1
# endif
#endif
void Foo()
#if defined(CXX17_EXCEPTIONS)
if (std::uncaught_exceptions() == 0)
#endif
int x = 0;
__EXCEPTIONS && __has_feature(cxx_exceptions)
is specific to Clang and detects if C++17 exceptions are available (including ObjectiveC++). __cpp_lib_uncaught_exceptions
is a C++ language feature and detects if C++17 exceptions are available.
It is not clear to me how __has_feature(cxx_exceptions)
returns true when C++17 exceptions are not available. It seems obvious (to me) the feature is not available.
Also see LLVM Issue 39631, __has_feature(cxx_exceptions)
returns true but fails to compile std::uncaught_exceptions()
.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253553%2ferror-uncaught-exceptions-is-unavailable-introduced-in-macos-10-12%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
The problem here is that the runtime library (libc++.dylib
) shipped on Mac OS before 10.12 does not contain a definition for std::uncaught_exceptions()
. If you were to try using it on those platforms, it would result on a linker error. So instead, we're warning you at compile-time that this would fail. This has nothing to do with exceptions being available/unavailable: it's about the specific function not being available.
add a comment |
up vote
2
down vote
The problem here is that the runtime library (libc++.dylib
) shipped on Mac OS before 10.12 does not contain a definition for std::uncaught_exceptions()
. If you were to try using it on those platforms, it would result on a linker error. So instead, we're warning you at compile-time that this would fail. This has nothing to do with exceptions being available/unavailable: it's about the specific function not being available.
add a comment |
up vote
2
down vote
up vote
2
down vote
The problem here is that the runtime library (libc++.dylib
) shipped on Mac OS before 10.12 does not contain a definition for std::uncaught_exceptions()
. If you were to try using it on those platforms, it would result on a linker error. So instead, we're warning you at compile-time that this would fail. This has nothing to do with exceptions being available/unavailable: it's about the specific function not being available.
The problem here is that the runtime library (libc++.dylib
) shipped on Mac OS before 10.12 does not contain a definition for std::uncaught_exceptions()
. If you were to try using it on those platforms, it would result on a linker error. So instead, we're warning you at compile-time that this would fail. This has nothing to do with exceptions being available/unavailable: it's about the specific function not being available.
answered Nov 12 at 13:15
Louis Dionne
2,347928
2,347928
add a comment |
add a comment |
up vote
1
down vote
__EXCEPTIONS && __has_feature(cxx_exceptions)
tests if exceptions are available. Exceptions are a language feature that has been in C++ since about 1990 (they weren't introduced in C++17!), so unless you explicitly disable exceptions they should always be available.
__cpp_lib_uncaught_exceptions
alone is the correct test.
add a comment |
up vote
1
down vote
__EXCEPTIONS && __has_feature(cxx_exceptions)
tests if exceptions are available. Exceptions are a language feature that has been in C++ since about 1990 (they weren't introduced in C++17!), so unless you explicitly disable exceptions they should always be available.
__cpp_lib_uncaught_exceptions
alone is the correct test.
add a comment |
up vote
1
down vote
up vote
1
down vote
__EXCEPTIONS && __has_feature(cxx_exceptions)
tests if exceptions are available. Exceptions are a language feature that has been in C++ since about 1990 (they weren't introduced in C++17!), so unless you explicitly disable exceptions they should always be available.
__cpp_lib_uncaught_exceptions
alone is the correct test.
__EXCEPTIONS && __has_feature(cxx_exceptions)
tests if exceptions are available. Exceptions are a language feature that has been in C++ since about 1990 (they weren't introduced in C++17!), so unless you explicitly disable exceptions they should always be available.
__cpp_lib_uncaught_exceptions
alone is the correct test.
answered Nov 14 at 21:14
MerryMage
111
111
add a comment |
add a comment |
up vote
0
down vote
I'm not sure if this is the correct way to handle the situation, but it may help others.
$ cat test.cxx
#if __EXCEPTIONS && __has_feature(cxx_exceptions)
# if __cpp_lib_uncaught_exceptions
# include <exception>
# define CXX17_EXCEPTIONS 1
# endif
#endif
void Foo()
#if defined(CXX17_EXCEPTIONS)
if (std::uncaught_exceptions() == 0)
#endif
int x = 0;
__EXCEPTIONS && __has_feature(cxx_exceptions)
is specific to Clang and detects if C++17 exceptions are available (including ObjectiveC++). __cpp_lib_uncaught_exceptions
is a C++ language feature and detects if C++17 exceptions are available.
It is not clear to me how __has_feature(cxx_exceptions)
returns true when C++17 exceptions are not available. It seems obvious (to me) the feature is not available.
Also see LLVM Issue 39631, __has_feature(cxx_exceptions)
returns true but fails to compile std::uncaught_exceptions()
.
add a comment |
up vote
0
down vote
I'm not sure if this is the correct way to handle the situation, but it may help others.
$ cat test.cxx
#if __EXCEPTIONS && __has_feature(cxx_exceptions)
# if __cpp_lib_uncaught_exceptions
# include <exception>
# define CXX17_EXCEPTIONS 1
# endif
#endif
void Foo()
#if defined(CXX17_EXCEPTIONS)
if (std::uncaught_exceptions() == 0)
#endif
int x = 0;
__EXCEPTIONS && __has_feature(cxx_exceptions)
is specific to Clang and detects if C++17 exceptions are available (including ObjectiveC++). __cpp_lib_uncaught_exceptions
is a C++ language feature and detects if C++17 exceptions are available.
It is not clear to me how __has_feature(cxx_exceptions)
returns true when C++17 exceptions are not available. It seems obvious (to me) the feature is not available.
Also see LLVM Issue 39631, __has_feature(cxx_exceptions)
returns true but fails to compile std::uncaught_exceptions()
.
add a comment |
up vote
0
down vote
up vote
0
down vote
I'm not sure if this is the correct way to handle the situation, but it may help others.
$ cat test.cxx
#if __EXCEPTIONS && __has_feature(cxx_exceptions)
# if __cpp_lib_uncaught_exceptions
# include <exception>
# define CXX17_EXCEPTIONS 1
# endif
#endif
void Foo()
#if defined(CXX17_EXCEPTIONS)
if (std::uncaught_exceptions() == 0)
#endif
int x = 0;
__EXCEPTIONS && __has_feature(cxx_exceptions)
is specific to Clang and detects if C++17 exceptions are available (including ObjectiveC++). __cpp_lib_uncaught_exceptions
is a C++ language feature and detects if C++17 exceptions are available.
It is not clear to me how __has_feature(cxx_exceptions)
returns true when C++17 exceptions are not available. It seems obvious (to me) the feature is not available.
Also see LLVM Issue 39631, __has_feature(cxx_exceptions)
returns true but fails to compile std::uncaught_exceptions()
.
I'm not sure if this is the correct way to handle the situation, but it may help others.
$ cat test.cxx
#if __EXCEPTIONS && __has_feature(cxx_exceptions)
# if __cpp_lib_uncaught_exceptions
# include <exception>
# define CXX17_EXCEPTIONS 1
# endif
#endif
void Foo()
#if defined(CXX17_EXCEPTIONS)
if (std::uncaught_exceptions() == 0)
#endif
int x = 0;
__EXCEPTIONS && __has_feature(cxx_exceptions)
is specific to Clang and detects if C++17 exceptions are available (including ObjectiveC++). __cpp_lib_uncaught_exceptions
is a C++ language feature and detects if C++17 exceptions are available.
It is not clear to me how __has_feature(cxx_exceptions)
returns true when C++17 exceptions are not available. It seems obvious (to me) the feature is not available.
Also see LLVM Issue 39631, __has_feature(cxx_exceptions)
returns true but fails to compile std::uncaught_exceptions()
.
answered Nov 12 at 10:12
jww
52.6k38220481
52.6k38220481
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253553%2ferror-uncaught-exceptions-is-unavailable-introduced-in-macos-10-12%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown