develooper Front page | perl.perl5.porters | Postings from March 2003

[PATCH] MakeMaker, XS and C++

Thread Next
Salvador Fandiño
March 18, 2003 14:35
[PATCH] MakeMaker, XS and C++
Message ID:

XS currently supports C++ but the generated files are named with the 
termination ".c" and so they are compiled by the C compiler instead of 
by the C++ one. Too work around this, CC has to be defined in the 
Makefile.PL script pointing to the C++ compiler. This is ugly and rather 

Looking at MakeMaker sources and p5p archives it seems that at some 
point rules to compile ".xs" to ".cpp" were added but that they were 
removed later because they caused a diamond relation that could break 
the make process:

    file.xs -->  file.c  --> file.o
    file.xs --> file.cpp --> file.o

there are two paths to go from .xs to .o and make doesn't know which one 
to take.

There is an obvious solution to this problem: to use a different 
termination for XS files containing C++ code, say .xss so

    file.xs -->  file.c  --> file.o
   file.xss --> file.cpp --> file.o

That's what the included MakeMaker patch does. Specifically, it ...

- defines new xss_cpp and xss_o subs to create Makefile rules ".xss.cpp" 
and ".xss.o"

- adds --xss option to h2xs to use that extension

- adds some docs to perlxs.pod

- tests for the new feature

I have only changed MM_Unix and MM_Win32/95, and only tested under 
linux, other architectures will also require changes, but I lack access 
to them (and the knowledge also) to do it.


     - salva

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About