Skip to content

Instantly share code, notes, and snippets.

@tiras-j
Created October 12, 2018 01:28
Show Gist options
  • Save tiras-j/ad7e54c50bee4beb3a01804259e4cd74 to your computer and use it in GitHub Desktop.
Save tiras-j/ad7e54c50bee4beb3a01804259e4cd74 to your computer and use it in GitHub Desktop.
libz-sys simplified stdout compilation test
test.c:
#include <stdio.h>
int main(int argc, char *argv[]) {
char buf[128] = {0};
printf("TESTING TESTING TESTING\n");
snprintf(buf, 128, "%s", "TESTING TESTING TESTING\n");
printf("%s", buf);
}
Failing options:
$ cc -O3 -fPIC -arch arm64 -miphoneos-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk -fembed-bitcode -DSTDC -D_LARGEFILE64_SOURCE -D_POSIX_SOURCE -o test test.c
test.c:8:5: error: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Werror,-Wimplicit-function-declaration]
snprintf(buf, 128, "%s", "TESTING TESTING TESTING\n");
^
test.c:8:5: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'
1 error generated.
Working options:
$ cc -O3 -fPIC -arch arm64 -miphoneos-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk -fembed-bitcode -DSTDC -D_LARGEFILE64_SOURCE -o test test.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment