On 01/10/2013 17:41, Robin Becker wrote:
I'm trying to port C code  that compiles under 2.7 to 3.3; the intention is to
make things work under both.

I used to use raw strings for the module documentation, but my porting guide
suggests that I should be using PyDoc_STRVAR. That works for me using linux, but
I'm getting errors under windows compiles

My usage looks like this


PyDoc_STRVAR(__DOC__,
"Helper extension module for xxx.\n\
\n\
Interface summary:\n\
\n\
        import _xxx\n\
        ......\n"
#ifdef  ZZZZ
"    ZZZZ stuff\n"
#endif
"\n\
        .........\n\
");


but it seems that the MSVC compiler for python-2.7 cannot hack this and I get
messages like this

_xxx.c
C:\code\hg-repos\test_ext\xxx\_xxx.c(66) : error C2121: '#' : invalid character 
: possibly the
result of a macro expansion
C:\code\hg-repos\test_ext\xxx\_xxx.c(66) : error C2146: syntax error : missing 
';' before ident
ifier 'ifdef'
C:\code\hg-repos\test_ext\xxx\_xxx.c(66) : error C2143: syntax error : missing 
'{' before 'cons
tant'
C:\code\hg-repos\test_ext\xxx\_xxx.c(66) : error C2059: syntax error : 
'<Unknown>'
C:\code\hg-repos\test_ext\xxx\_xxx.c(66) : error C2121: '#' : invalid character 
: possibly the
result of a macro expansion
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' 
failed with exit status 2

line 66 is the closing paranthesis.

Anyone got any ideas?

Previously I used code like this

static char moduleDoc ="Helper extension module for xxx.\n\
\n\
Interface summary:\n\
\n\
        import _xxx\n\
        ......\n"
#ifdef  ZZZZ
"    ZZZZ stuff\n"
#endif
"\n\
        .........\n\
";

but the registration and usage differs quite a lot between python2 & python3 so
I thought to switch to the newer mechanism.

I've tried it in a minimal console program, and it seems to work for me.

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to