PyDoc_STRVAR error in msvc compile

R

Robin Becker

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,961
Messages
2,570,130
Members
46,689
Latest member
liammiller

Latest Threads

Top