| 1 | // |
| 2 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 3 | // See https://llvm.org/LICENSE.txt for license information. |
| 4 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 5 | |
| 6 | /* |
| 7 | * structmember.c |
| 8 | * testObjects |
| 9 | * |
| 10 | * Created by Blaine Garst on 9/30/08. |
| 11 | * CONFIG |
| 12 | */ |
| 13 | #include <Block.h> |
| 14 | #include <Block_private.h> |
| 15 | #include <stdio.h> |
| 16 | |
| 17 | // CONFIG |
| 18 | |
| 19 | int main(int argc, char *argv[]) { |
| 20 | struct stuff { |
| 21 | long int a; |
| 22 | long int b; |
| 23 | long int c; |
| 24 | } localStuff = { 10, 20, 30 }; |
| 25 | int d; |
| 26 | |
| 27 | void (^a)(void) = ^ { printf(format: "d is %d" , d); }; |
| 28 | void (^b)(void) = ^ { printf(format: "d is %d, localStuff.a is %lu" , d, localStuff.a); }; |
| 29 | |
| 30 | unsigned nominalsize = Block_size(b) - Block_size(a); |
| 31 | #if __cplusplus__ |
| 32 | // need copy+dispose helper for C++ structures |
| 33 | nominalsize += 2*sizeof(void*); |
| 34 | #endif |
| 35 | if ((Block_size(b) - Block_size(a)) != nominalsize) { |
| 36 | printf(format: "sizeof a is %ld, sizeof b is %ld, expected %d\n" , Block_size(a), Block_size(b), nominalsize); |
| 37 | printf(format: "dump of b is %s\n" , _Block_dump(b)); |
| 38 | return 1; |
| 39 | } |
| 40 | printf(format: "%s: Success\n" , argv[0]); |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | |
| 45 | |