
On 4/24/2012 12:22 AM, Stephan T. Lavavej wrote:
[Paul Mensonides]
It isn't that. VC++ doesn't even implement the preprocessor correctly for C89. Essentially, the macro expansion algorithm appears to be fundamentally broken. One small example: #define A() 123 #define B() () A B() // should expand to A() (and does) #define C() A B() C() // should *still* expand to A() (but instead expands to 123)
I have filed this as DevDiv#407151 "VC's preprocessor considered harmful (to Boost.Preprocessor)" in our internal database, including a copy of your entire mail.
If it were within my power to fix this for you, I would - but I am not a compiler dev.
If you look at the Microsoft bug reporting page for preprocessors errors you will see other problems with the preprocessor. A number of these are basically the same problem with variadic macros, but others are just basic erroneous proocessing of prepeocessor input and Microsoft's response often is that it is the way the VC++ preprocessor works and will not be changed even if it is erroneous. Here are some links: https://connect.microsoft.com/VisualStudio/feedback/details/385034/preproces... https://connect.microsoft.com/VisualStudio/feedback/details/380090/variadic-... https://connect.microsoft.com/VisualStudio/feedback/details/548580/c-preproc... https://connect.microsoft.com/VisualStudio/feedback/details/676585/bug-in-cl... https://connect.microsoft.com/VisualStudio/feedback/details/718976/msvc-prep... https://connect.microsoft.com/VisualStudio/feedback/details/318940/macro-exp... https://connect.microsoft.com/VisualStudio/feedback/details/306850/c-preproc... https://connect.microsoft.com/VisualStudio/feedback/details/288202/preproces... https://connect.microsoft.com/VisualStudio/feedback/details/177051/invalid-p... I know this is overkill to list these here, but it really is not done as an attempt to embarass you or Microsoft. Rather it is proof of what Paul has said, that Microsoft has taken the view that it is not important to fix the prerocessor. Even if Microsoft were concerned with breaking backward compatibility, ie. breaking code which uses the incorrect implementation, in changing the preprocessor to actually be correct, they could create a correct preprocessor and have a compiler switches to enable the backward compatibility mode or the correct preprocessor mode if they did so.