PyDoc_STRVAR error in msvc compile

Dave Angel davea at davea.name
Wed Oct 2 08:05:02 EDT 2013


On 2/10/2013 07:28, Robin Becker wrote:


> The actual is this code from _renderPM.c
>
> https://bitbucket.org/rptlab/reportlab/src/fa65fe72b6c2aaecb7747bf14884adb996d8e87f/src/rl_addons/renderPM/_renderPM.c?at=default
>
> PyDoc_STRVAR(__DOC__,
> "Helper extension module for renderPM.\n\
> \n\
> Interface summary:\n\
> \n\
>          import _renderPM\n\
>          gstate(width,height[,depth=3,bg=0xffffff]) #create an initialised 
> graphics state\n\
>          makeT1Font(fontName,pfbPath,names[,reader])     #make a T1 font\n\
>          delCache() #delete all T1 font info\n\
>          pil2pict(cols,rows,datastr,palette) hreturn PICT version of im as bytes\n"
> #ifdef  RENDERPM_FT
> "    ft_get_face(fontName) --> ft_face instance\n"
> #endif
> "\n\
>          _libart_version # base library version string\n\
>          _version                # module version string\n\
> ");
>
> when I run that through the pre-processor I get (all on a single line)
>
>
> static char __DOC__[] = "Helper extension module for renderPM.\n\nInterface 
> summary:\n\n	import _renderPM\n	gstate(width,height[,depth=3,bg=0xffffff]) 
> #create an initialised graphics state\n 
> makeT1Font(fontName,pfbPath,names[,reader])	#make a T1 font\n	delCache() #delete 
> all T1 font info\n	pil2pict(cols,rows,datastr,palette) hreturn PICT version of 
> im as bytes\n" #ifdef 1 "    ft_get_face(fontName) --> ft_face instance\n" 
> #endif "\n	_libart_version	# base library version string\n	_version		# module 
> version string\n";
>
>
>
> I tried a couple of variations of \ at the end of the line preceding #ifdef etc 
> etc, but nothing seemed to work. The source is properly DOS formatted (according 
> to vim) so it's not a simple line ending issue and I don't have any extra spaces 
> at the end of the lines etc etc.

Unfortunately, bitbucket doesn't properly support highlighting either,
so I had to copy/paste it into an editor to check for extra spaces. 
That's apparently not your problem.

What I didn't understand before is that PyDoc_STRVAR is a macro, not a
function.  And inside the macro's parameters, you're trying to define an
#ifdef.  i don't think Microsoft supports that.

If I'm right, you need to separate out the conditional string
concatenation from the macro expansion.  it's been too long for me even
to remember the correct way to do that.  There are some legal tricks you
can use.  Maybe search the internet for "preprocessor stringizing".



-- 
DaveA





More information about the Python-list mailing list