PDA

View Full Version : The buggy MSVC...


Maximus
February 7th, 2010, 19:16
well,

this is a bit funny... I am working in a project using multiple compilers. So far, nothing strange: every compiler has its own idioms.
It is also well known that MSVC cpp (c preprocessor) is a bit buggy, but...
look to the hack I had to do to compile a piece of code that compiles flawlessy on other compilers:

Code:

void func()
{
...
//
MY_CODE_IN_MACRO(...);
#ifdef MS_FIX_BUGGY_CPP_VERY_UGLY_HACK
};
};
};
#endif
...
};

the fun is, if I generate the ".i" files the cpp correctly expands the macro (so the #conditional block is not needed) but as long as I compile it normally, it complais of those missing closing brackets!!

---
well, that's interesting: now it compiles, but it totally REFUSE to generate the proper code, which it generates if the macro is... not macroed (and there it complais not of the brackets). Bah.
---
well, in the end, it seems that it is due to the fact that the code contains inline __asm statements: probably the compiler isnt capable of expanding assembler AND macro at the same time...

tofu-sensei
February 8th, 2010, 07:26
did you have a look at this
http://msdn.microsoft.com/en-us/library/352sth8z.aspx
?

Maximus
March 1st, 2010, 16:16
Hi,

thanks alot, that solved my issue!

I did try to write down even single asm statemets, but without any success.
By the way, I'd like to point that "__asm opcode; __asm opcode;" won't work, but indeed IT SHOULD, as the ';' is used for comment *within* an asm block, and not after the single instruction -on such context, it *is* a c-statement terminator!

Quote:
Assembly-style comments that start with a semicolon ( continue to the end of the line. This causes problems in macros because the compiler ignores everything after the comment


__asm opcode;__asm opcode; should work, but it will not. bah.

Well, thanks alot