Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #55229

Re: PyDoc_STRVAR error in msvc compile

Date 2013-10-01 18:26 +0100
From MRAB <python@mrabarnett.plus.com>
Subject Re: PyDoc_STRVAR error in msvc compile
References <524AFB57.9090500@chamonix.reportlab.co.uk>
Newsgroups comp.lang.python
Message-ID <mailman.566.1380648371.18130.python-list@python.org> (permalink)

Show all headers | View raw


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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: PyDoc_STRVAR error in msvc compile MRAB <python@mrabarnett.plus.com> - 2013-10-01 18:26 +0100

csiph-web