Skip to content

Instantly share code, notes, and snippets.

@emilaxelsson
Created April 19, 2016 15:04
Show Gist options
  • Save emilaxelsson/51310b3353f96914cd9bdb18b10b3103 to your computer and use it in GitHub Desktop.
Save emilaxelsson/51310b3353f96914cd9bdb18b10b3103 to your computer and use it in GitHub Desktop.
Test of tgmath.h
// This file demonstrates that if `tgmath.h` is included, it doesn't matter if
// `math.h` is also included and which order the include statements appear.
#include <stdio.h>
#include <tgmath.h>
#include <math.h>
int main() {
printf("%.20f\n", sinf((float) 5.0));
printf("%.20f\n", sin((double) 5.0));
printf("%.20f\n", sin((float) 5.0));
}
// The first two lines print the same result regardless of the includes. The
// last line behaves like `sinf` if and only if `tgmath.h` is included.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment