I'm implementing a DSL with a compiler that translates it into C. Our code is self-contained: we provide users with just one main entry point (i.e., void step()
), all inputs are given in global variables with simple types (bool, signed/unsigned ints, double, float, structs, and arrays; but no pointers, and no functions as inputs).
Our main target is C99, but some people are using the arduino compiler for the code we produce, so maximum portability across standards and compilers is preferred.
I see that C99's math.h
defines multiple variants of functions based on the type of the arguments (e.g., sin
, sinf
, sinl
).
To avoid losing precision, our translator can, based on the types of the arguments, pick one of those variants. However, all functions we support are also defined by tgmath.h
, so a simpler way would be to use the standard name for each (e.g., sin
) and let tgmath.h
pick the appropriate variant based on the types of the arguments.
I've read online that opinions on tgmath.h
, and support, are mixed. Some people say it is ugly, and that not all compilers support it.
Is relying on tgmath.h
a bad idea? Is this going to give us headaches down the line?