|
-
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
-
January 1st, 2011, 01:11 PM
#2
Re: logf macro in math.h
 Originally Posted by John E
[Edit...] Amazingly, I've discovered a bug in math.h. the macro for logf incorrectly has a semicolon at the end - i.e
Code:
#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!
Hi John,
I have searched in all MATH.H from my computer (VC6.0/2005/2008/2010) and did not found any logf macro as you described.
Just
Code:
#define logf(x) ((float)log((double)(x)))
with no semicolon.
Are you sure that yours isn't from onother third party library or was not modified by mistake?
-
January 1st, 2011, 01:49 PM
#3
Re: logf macro in math.h
Invariably I add an annotation to a 3rd party file if I modify it so I don't think that's the problem. It's more likely that you've installed a service pack which I haven't got (in fact, I don't think I've installed any service packs at all yet for VS2005).
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
January 1st, 2011, 02:34 PM
#4
Re: logf macro in math.h
Indeed, I've installed service packs as well as SDK updates.
I will verify ASAP on a "clean" install.
-
January 1st, 2011, 03:00 PM
#5
Re: logf macro in math.h
I have the Professional edition (on CD) and the Express edition which I downloaded. Only the Professional edition seems to have the problem. It has two copies of math.h (which strangely, aren't the same size) but both copies seem to be affected.
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
January 1st, 2011, 06:38 PM
#6
Re: logf macro in math.h
Good spot; well done. Get the service pack to fix it.
http://connect.microsoft.com/VisualS...ling-semicolon
-
January 2nd, 2011, 09:22 AM
#7
Re: logf macro in math.h
Well then, problem is solved.
-
January 2nd, 2011, 10:29 AM
#8
Re: logf macro in math.h
Must get around to installing that service pack..!
"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
|