Bug? #if statement + //comment = error

Is this a bug?


#define STATEMENT 0

#if STATEMENT == 0 //Comment
#endif

ERROR(SCR.SCN6) : C:/C…/*.any(3) : ‘0’ : Unexpected character.


#define STATEMENT 0

#if STATEMENT == 0 
//Comment
#endif

Works fine.

Hi,

No, this is, what is called, imperfections of the AnyBody Modeling System.

The problem is that this is a preprocessor command that will take all arguments and try to use them all - meaning that it will try to use this comment line as a part of the expression before that. Obviously substituting an equation argument with something that contains a comment line in middle will break this equation. And this is exactly the case here.

So please do not comment on the preprocessor command lines (starting with #).

Kind regards,
Pavel

Hi,

I believe that this is actually a bug.

C has a preprocessor similar to the one in AnyBody. When you add comments to a preprocessor line in C the compiler should strip the reminder of the line replacing it with a whitespace. This also happens in AnyBody, but it appears that AnyBody also replaces the newline character by mistake.

It also means that you can fix the problem by adding an empty line after #if statement. So this should work:

#define STATEMENT 0
#if STATEMENT == 0 //Comment

//…
//…
#endif