"Expression Expected" error with macro functions

Hi!

AppCode seems to have a problem with our logging macro. Code looks like this:

LOG_INFO(@"Message.");

And the error message for that line is "Expression Expected".


Macro is defined as:

#define LOG_INFO(s,...) LOG_LOG(@"INFO", LOG_LEVEL_INFO, s, ##__VA_ARGS__)


LOG_LOG macro is defined as:

#define LOG_LOG(lname, llevel, s, ...) \
do { \
     // do the logging stuff using ##__VA_ARGS__ etc...
} while(0)




The code compiles fine, and neither gcc nor clang have any problems with it. I know C macros can be hairy, but I'd hope this could be fixed in AppCode, because we use logging everywhere in our code and it isn't nice to see AppCode think all the files have errors.

Thanks again for making AppCode!
0
6 comments
Avatar
Permanently deleted user

Hi!

Unfortunately (or fortunately it is?) I wasn't able to reproduce the problem. Can I have a complete sample code?

0
Avatar
Permanently deleted user

Hi!

Sorry about the bad code. I hope this is complete enough for you to replicate the problem. At least for me it showed the warning when pasted to any Objective-C file.

Thanks for looking into this! And good luck fixing :)


@interface Logger : NSObject
+(void)logFormat:(NSString*)format, ...;
@end




extern int gLogLevel;


#define LOG_LOG(level, s, ...) \
do { \
     if(level <= gLogLevel)\
     {\
          [Logger logFormat:s, ##__VA_ARGS__]; \
     }\
} while(0)




#define LOG_INFO(s,...) LOG_LOG(1, s, ##__VA_ARGS__)




@interface MyViewController : UIViewController
{}
@end


@implementation MyViewController


-(void) viewDidUnload
{
     [super viewDidUnload];
     
     LOG_INFO(@"Message.");

}


@end
0
Avatar
Permanently deleted user

Got it!

-- gone fixing

0
Avatar
Permanently deleted user
0
Avatar
Permanently deleted user

Superb! Thanks! Really looking forward to the next build.

0
Avatar
Permanently deleted user

I'm experiencing the same problem with 106.624 - should your fix be part of this new build?

regards,

Christian K. Ibsen

0

Please sign in to leave a comment.