Skip to content

Commit

Permalink
Win64: Only use __builtin_setjmp/__builtin_longjmp when compiling…
Browse files Browse the repository at this point in the history
… with GCC

Using `__builtin_setjmp` when compiling with Clang on MSYS2 will result in compiler warnings and runtime crashes.  It seems to work on GCC, though.

Compiler warning on Clang:

warning: incompatible pointer types passing 'jmp_buf' (aka 'struct _SETJMP_FLOAT128[16]') to parameter of type 'void **' [-Wincompatible-pointer-types]
                NS_DURING
                ^~~~~~~~~
note: expanded from macro 'NS_DURING'
                    if (!setjmp(NSLocalHandler.jumpState)) {
                                ^~~~~~~~~~~~~~~~~~~~~~~~
note: expanded from macro 'setjmp'
#define setjmp(X)       __builtin_setjmp(X)
                                         ^
1 warning generated.
  • Loading branch information
qmfrederik committed Oct 7, 2023
1 parent 24653e6 commit 1e737c6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Headers/Foundation/NSException.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include <setjmp.h>
#include <stdarg.h>

#if defined(__WIN64__)
#if defined(__WIN64__) && defined(__GNUC__)
/* This hack is to deal with the fact that currently (June 2016) the
* implementation of longjmp in mingw-w64 sometimes crashes in msvcrt.dll
* but the builtin version provided by gcc seems to work.
Expand Down

0 comments on commit 1e737c6

Please sign in to comment.