// filename:c2011-6-7-4-ex.c
// original examples and/or notes:
// 		(c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
// 			C2011 6.7.4 Function specifiers
// compile and output mechanism:
// 		(c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.xx, 2013
// compile errors and/or wornings:
// 1	(c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
// 			Target: x86_64-apple-darwin11.4.2 //Thread model: posix
// 		(c) LLVM 2003-2009 University of Illinois at Urbana-Champaign.
// 2    gcc-4.9 (GCC) 4.9.0 20131229 (experimental)
//      Copyright (C) 2013 Free Software Foundation, Inc.
#include <stdio.h>
#include <stdlib.h>

// Example 1
inline double fahr(double t){
return (9.0 * t) / 5.0 + 32.0;
}
inline double cels(double t){
return (5.0 * (t - 32.0)) / 9.0;
}

extern double fahr(double); // creates an external definition
extern double cels(double);

double convert(int is_fahr, double temp){
/* A translator may perform inline substitutions */
return is_fahr ? cels(temp) : fahr(temp);
}
// Example 2
_Noreturn void f (void) {
abort(); // ok
}
_Noreturn void g (int i) { // causes undefined behavior if i <= 0
if (i > 0) abort();
}
int main(void)
{
	double t;
	convert(1,t);
return printf("6.7.4 Function specifiers %f %f %f\n",fahr(t),cels(t),(t));	
}
// warning GCC4.9
// c2011-6-7-4-ex.c: In function 'g':
// c2011-6-7-4-ex.c:35:1: warning: 'noreturn' function does return [enabled by default]
// }
// ^
// output may be
// 6.7.4 Function specifiers 32.000000 -17.777778 0.000000
