[Python-Dev] How to make _sre.c compile w/ C++?

2006-04-17 Thread skip

I checked in a number of minor changes this evening to correct various
problems compiling Python with a C++ compiler, in my case Apple's version of
g++ 4.0.  I'm stuck on Modules/_sre.c though.  After applying this change:

Index: Modules/_sre.c
===
--- Modules/_sre.c  (revision 45497)
+++ Modules/_sre.c  (working copy)
@@ -2284,10 +2284,10 @@
 ptr = getstring(ptemplate, n, b);
 if (ptr) {
 if (b == 1) {
-literal = sre_literal_template(ptr, n);
+   literal = sre_literal_template((SRE_CHAR *)ptr, n);
 } else {
 #if defined(HAVE_UNICODE)
-literal = sre_uliteral_template(ptr, n);
+   literal = sre_uliteral_template((Py_UNICODE *)ptr, n);
 #endif
 }
 } else {

I am left with this error:

../Modules/_sre.c: In function 'PyObject* pattern_subx(PatternObject*, 
PyObject*, PyObject*, int, int)':
../Modules/_sre.c:2287: error: cannot convert 'Py_UNICODE*' to 'unsigned char*' 
for argument '1' to 'int sre_literal_template(unsigned char*, int)'

During the 16-bit pass, SRE_CHAR expands to Py_UNICODE, so the call to
sre_literal_template is incorrect.  Any ideas how to fix things?

As clever as the two-pass compilation thing is, I must admit it confuses me.

Thx,

Skip

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] How to make _sre.c compile w/ C++?

2006-04-17 Thread Anthony Baxter
On Tuesday 18 April 2006 11:27, [EMAIL PROTECTED] wrote:
 During the 16-bit pass, SRE_CHAR expands to Py_UNICODE, so the call
 to sre_literal_template is incorrect.  Any ideas how to fix things?

I thought (but haven't had time to test) that making getstring return 
a union that's either SRE_CHAR* or Py_UNICODE* would make the problem 
go away. 


-- 
Anthony Baxter [EMAIL PROTECTED]
It's never too late to have a happy childhood.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] How to make _sre.c compile w/ C++?

2006-04-17 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote:
  if (b == 1) {
 -literal = sre_literal_template(ptr, n);
 +   literal = sre_literal_template((SRE_CHAR *)ptr, n);
  } else {
  #if defined(HAVE_UNICODE)
 -literal = sre_uliteral_template(ptr, n);
 +   literal = sre_uliteral_template((Py_UNICODE *)ptr, n);
  #endif
 ../Modules/_sre.c: In function 'PyObject* pattern_subx(PatternObject*, 
 PyObject*, PyObject*, int, int)':
 ../Modules/_sre.c:2287: error: cannot convert 'Py_UNICODE*' to 'unsigned 
 char*' for argument '1' to 'int sre_literal_template(unsigned char*, int)'
 
 During the 16-bit pass, SRE_CHAR expands to Py_UNICODE, so the call to
 sre_literal_template is incorrect.  Any ideas how to fix things?

sre_literal_template doesn't take SRE_CHAR*, but unsigned char*. So just
cast to that.

Regards,
Martin
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com