Let someone vote for my own answer to my own question.
Thanks to the idea of Martin York, I found that in Visual Studio the solution looks very simple (subject to further testing). Just rename ALL preprocessor directives to something else (something invalid C ++ syntax is fine) and use cl.exe with / P
cl target.cpp /P
a target.i. . , . , #line, cl.exe.
, , MSDN, :
. Trigraph .
, () , , . , , .
. . .
. #include , .
escape- . Microsoft C ++ , ASCII.
. , "String" " ".
; .
Tokenization Preprocessing. ,
( ), 3 .
.h, /FI, . .i .cpp .h. . # . . , , / , .
, - . ( ).
.
-#include "stdafx.h"
-#include <windows.h>
-#define NOERR
-#ifdef NOERR
whatever error line is ok
-#else
some error line if NOERR not defined
-#endif
void pr() ;
int _tmain(int argc, _TCHAR* argv[])
{
pr();
return 0;
}
void pr() {
printf(" /* ");
continue a comment line
printf(" ");
printf\
("some weird lines \
with line continuation");
}
cl.exe vc8.cpp /P cl.exe ( # )
#line 1 "vc8.cpp"
-#include "stdafx.h"
-#include <windows.h>
-#define NOERR
-#ifdef NOERR
whatever error line is ok
-#else
some error line if NOERR not defined
-#endif
void pr() ;
int _tmain(int argc, _TCHAR* argv[])
{
pr();
return 0;
}
void pr() {
printf(" /* ");
printf(" ");
printf\
("some weird lines \
with line continuation");
}