dyld-750.5.tar.gz
[apple/dyld.git] / testing / test-cases / dylib-static-weak-link.dtest / present.c
1 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/libfoo.dylib -install_name $RUN_DIR/libfoo.dylib
2 // BUILD: $CC present.c $BUILD_DIR/libfoo.dylib -o $BUILD_DIR/dylib-static-weak-present.exe
3 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/libfoo2.dylib -install_name $RUN_DIR/libfoomissing.dylib
4 // BUILD: $CC missing.c $BUILD_DIR/libfoo2.dylib -o $BUILD_DIR/dylib-static-weak-missing.exe
5
6 // BUILD: $SKIP_INSTALL $BUILD_DIR/libfoo2.dylib
7
8 // RUN: ./dylib-static-weak-present.exe
9 // RUN: ./dylib-static-weak-missing.exe
10
11
12 #include <stddef.h>
13 #include <stdio.h>
14
15 #include "test_support.h"
16
17 extern int foo __attribute__((weak_import));
18
19
20 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
21 // dylib will be found at runtime, so &foo should never be NULL
22 if ( &foo != NULL ) {
23 if ( foo == 42 )
24 PASS("Success");
25 else
26 FAIL("Wrong value");
27 }
28 else {
29 FAIL("&foo == NULL");
30 }
31 }
32
33