Force C99 Compliant Compilation in clang

Viewed 899

I am trying to write some C99 code that needs to compile on solaris in c99 mode, but I don't have access to a solaris machine. Instead, I'm trying to do this on OSX with clang. However, using (file min.c):

#include <stdio.h>
#include <string.h>

int main() {
  printf("%d\n", (int) strnlen("hello world", 5));
  return 0;
}

I don't get any errors or warnings about strnlen

$ clang -std=c99 -pedantic-errors -Wall -Wextra min.c
$ ./a.out
5

even though strnlen is a 2008 posix extension.

This with:

Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Is there any way to get clang to strictly conform to c99 so that I have a better chance at portability wrt solaris?

2 Answers
Related