diff --git a/core/sys/darwin/Foundation/objc.odin b/core/sys/darwin/Foundation/objc.odin index 82d6199ce..52832c43b 100644 --- a/core/sys/darwin/Foundation/objc.odin +++ b/core/sys/darwin/Foundation/objc.odin @@ -1,8 +1,10 @@ package objc_Foundation foreign import "system:Foundation.framework" -// NOTE: Most of our bindings are reliant on Cocoa (everything under appkit) so just unconditionally import it -@(require) foreign import "system:Cocoa.framework" +when !ODIN_PLATFORM_SUBTARGET_IOS { + // Most macOS bindings rely on Cocoa through AppKit. + @(require) foreign import "system:Cocoa.framework" +} import "base:intrinsics" import "core:c" diff --git a/tests/issues/run.bat b/tests/issues/run.bat index b1242ffeb..1beb880d9 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -46,6 +46,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused ..\..\..\odin test ..\test_issue_bool_to_be_conversion.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_bool_comparison_truthiness.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_const_array_broadcast.odin %COMMON% || exit /b +..\..\..\odin check ..\test_issue_7336.odin -no-entry-point %COMMON% || exit /b ..\..\..\odin check ..\test_issue_ellipsis_type_call.odin -no-entry-point %COMMON% 2>&1 | find /c "Error:" | findstr /x "10" || exit /b ..\..\..\odin check ..\test_issue_foreign_redeclaration.odin -no-entry-point %COMMON% || exit /b ..\..\..\odin check ..\test_issue_foreign_redeclaration_mismatch.odin -no-entry-point %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b diff --git a/tests/issues/run.sh b/tests/issues/run.sh index 5395ad627..41a0835b4 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -93,6 +93,7 @@ $ODIN check ../test_issue_7012.odin -no-entry-point $COMMON_CHECK $ODIN build ../test_issue_7037.odin $COMMON -o:none $ODIN check ../test_issue_7429.odin $COMMON_CHECK $ODIN test ../test_issue_7356.odin $COMMON +$ODIN test ../test_issue_7336.odin $COMMON $ODIN build ../test_issue_7167.odin $COMMON $ODIN build ../test_issue_7188.odin $COMMON $ODIN check ../test_issue_7260.odin -no-entry-point $COMMON_CHECK diff --git a/tests/issues/test_issue_7336.odin b/tests/issues/test_issue_7336.odin new file mode 100644 index 000000000..305b4a974 --- /dev/null +++ b/tests/issues/test_issue_7336.odin @@ -0,0 +1,20 @@ +// Tests issue #7336 https://github.com/odin-lang/Odin/issues/7336 +package test_issues + +import "core:testing" + +S :: struct { + a: [dynamic; 1]matrix[4, 4]f32, + b: matrix[4, 4]f32, +} + +@(test) +test_offset :: proc(t: ^testing.T) { + s := new(S) + defer free(s) + + // 4*4 f32 + dynamic len == 72 + expect: uintptr = 4 * 4 * 4 + size_of(int) + testing.expect(t, offset_of(S, b) == expect) + testing.expect(t, uintptr(rawptr(&s.b)) - uintptr(rawptr(s)) == expect) +}