|
-
January 1st, 2011, 11:32 AM
#1
logf macro in math.h
Code:
#include <math.h>
void SomeFunc()
{
float_t winlen = 4;
float_t rayparam = 48./512. * winlen;
float dfwvnorm = expf ( (logf(2.0)/rayparam) * (winlen+2) ); // <-- compiler error if I use 'logf' but not if I use 'log'
}
I'm trying to build libaubio using VC++8. There's a function that essentially boils down to the above, once I've allowed for a couple of #defines (EXP and LOG, respectively).
If I use (log(2.0)/rayparam) my compiler seems happy. But if I use (logf(2.0)/rayparam) (which was originally intended in the code) the compiler complains with error C2143: syntax error : missing ')' before ';'. And yet from looking at math.h, logf is defined everywhere that expf is defined. AFAICT they're defined as functions for 64-bit compiles and as macros for 32-bit (mine's 32-bit). Can anyone suggest a reason why the compiler is happy to accept the expf macro but not logf?
[Edit...] Amazingly, I've discovered a bug in math.h. the macro for logf incorrectly has a semicolon at the end - i.e
#define logf(x) ((float)log((double)(x)));
Currently I'm using VC2005 Professional but previously I'd been using VC2005 Express. I've just looked in the Express version's copy of math.h and that doesn't have the problem!
Last edited by John E; January 1st, 2011 at 12:24 PM.
"A problem well stated is a problem half solved.” - Charles F. Kettering
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|