I'm working on a piece of code for an ARM processor running the Cortex-M4 architecture (has single precision floats but not double). The issue I'm running into is when using varargs and the compiler tries to promote my floats into doubles. Is there any way to turn this off? Or specify a different promotion strategy? I've looked in the GCC manuals but couldn't find anything. A simple example is trying to write your own printf...
void myprintf(const char *fmt, ...) {
// .. parse fmt and come across %f
double dv = va_arg(args, double); // Compiles but doesn't link
float fv = va_arg(args, float); // Doesn't compile (warns about promotion)
}
UPDATE: As requested, the call command I'm looking to use is myprintf("%f", 1.0f);. The issue is that the Cortex-M4 doesn't support doubles, so when 1.0f is promoted to a double... well it can't. So reading it back using va_arg(args, double) will compile but won't link as the various __aeabi_ functions related to doubles don't exist. What I want to do is disable GCC's promotion of floats to doubles (if possible).
UPDATE: I have a current workaround that basically just accepts pointers to floats instead of floats. I'd still like to disable the promotion as this isn't a great solution.