Skip to content

Commit 5b06efc

Browse files
authored
Fix julia.h for use in MSVC (#57654)
Since `__attribute__` is only valid for (mostly?) GCC and Clang, building libraries against Julia with MSVC is currently not working. This change should fix that.
1 parent d9922ec commit 5b06efc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/julia.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,15 @@ static const uint8_t PARTITION_FLAG_DEPRECATED = 0x20;
727727
// where calling the function itself will provide a (better) deprecation warning/error.
728728
static const uint8_t PARTITION_FLAG_DEPWARN = 0x40;
729729

730-
typedef struct __attribute__((aligned(8))) _jl_binding_partition_t {
730+
#if defined(_COMPILER_MICROSOFT_)
731+
#define JL_ALIGNED_ATTR(alignment) \
732+
__declspec(align(alignment))
733+
#else
734+
#define JL_ALIGNED_ATTR(alignment) \
735+
__attribute__((aligned(alignment)))
736+
#endif
737+
738+
typedef struct JL_ALIGNED_ATTR(8) _jl_binding_partition_t {
731739
JL_DATA_TYPE
732740
/* union {
733741
* // For ->kind == PARTITION_KIND_GLOBAL

0 commit comments

Comments
 (0)