views:

29

answers:

1

Hey Guys, At the moment im driving crazy with a simple problem. I cannot imagine what's wrong here.

In BlaBlaBla_prefix.pch I define the following:

#import "SMDeviceManager.h"
#define DeviceSpecificResourceName(name) [SMDeviceManager deviceSpecificResourceName:(name)];

But if I know use this function in my code inside a NSog()-call, I get the following error during compilation:

Expected ")" before ";" token.

But if I save the output in a variable ,instead of directly calling the function in NSLog, it works.

NSString *test = DeviceSpecificResourceName(@"eintest.png");
NSLog(@"%@", test);

This logs the expected value. B But in the other way it fails at compiling. What am I doing wrong? Can you please help me?

+5  A: 
#define DeviceSpecificResourceName(name) [SMDeviceManager deviceSpecificResourceName:(name)];
//                                                                                          ^ remove

Remove the final semicolon.


If you keep the ;, the statement NSLog(@"%@", DeviceSpecificResourceName(@"eintest.png")) will be replaced as

NSLog(@"%@", [SMDeviceManager deviceSpecificResourceName:(@"eintest.png")];);
//                                                                        ^

which of course is a syntax error.

KennyTM
How stupid of me! That's it. Thank you very much. It's not the first time I made this error. But this time I didn't look for the error in the #define part... Thank you for your answer!
Sandro Meier