[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Modules] Extension not printing to MacPerl window



I'm a newbie to MacPerl (and to Perl) and I'm learning about extensions.
I'm using MacPerl Power and Ease (MPPE), and trying the 'XPlusX' example on
starting on page 332 in Chapter 23 (full code at the end of this message).

After finding all the appropriate libraries (I'm using CodeWarrior MPW from
CodeWarrior Pro 4) I can get it linking and building (using Matthias
Neerarcher's dmake and BuildProgram) and I can install it, with no errors
(only warnings that 'identifier ssize-t is redeclared', which sounds
innocuous).  MacPerl reports no errors when I try to run the script.
However, I get no output in the MacPerl window.

I've put DebugStr() statements before and after the "printf" in the .xs
file, and they both triggered macsbug.  I put print commands in the perl
script before and after the call to the extensions, and their output
appears in the MacPerl window.

If I run the script from MPW (using the perl tool), it does exactly the
same thing (with no output from x_plus_x, breaks into macsbug, and all
other output appears).

Examining the assembly between the DebugStr()s, I see calls to something
that looks like a library; the value in r3 is the correct string
("%0.f\n"), it's doing a floating point add &c &c, but then trying to
follow the code into the library can be a black hole for time...

I note that in MPPE the section on building MacPerl, it says that  I must
do things like rename my folder from 'CodeWarrior MPW' to 'MPW', and get
some files specifically from CodeWarrior 11 (about six releases ago).  It
doesn't say I must do that to build *any* extension, but it doesn't say
that I don't, either.  Arved Sandstrom's site with mpxstut seems to
indicate that this is not necessary any more, so I'm still using CW Pro 4's
libraries (exactly as he has them in mpsxtut).  Also, as instructed in
MPPE, I executed CW_Max_Dup_Update to get the right libraries.

Any help would be greatly appreciated.  Thanks,
Rudi

PS. And thanks to Chris Nandor and Paul Schinder for getting me this far.

I'm on a 7300/180 (PPC 603 processor) with MacOS 8.5.1 and plenty of RAM.

The entire source from which I build my extension:

----------------------- script ------------------------
#!/usr/local/scripts/perl -lw

use XPlusX;
print "About to call extension\n";
XPlusX::x_plus_x(2.4);
print "Just called extension\n";

---------------------- XPlusX.pm ----------------------
package XPlusX;
require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(x_plus_x);
$VERSION = '0.01';
bootstrap XPlusX $VERSION;
1;

---------------------- XPlusX.xs ----------------------
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

MODULE = XPlusX PACKAGE = XPlusX

void
x_plus_x(num)
	double num
	CODE:
		DebugStr("\pAbout to printf...");
		printf("%.0f\n", num + num);
		DebugStr("\pJust did printf...");

--------------------- MakeFile.PL ---------------------
use ExtUtils::MakeMaker;
WriteMakefile(
	'NAME'			=>	'XPlusX',
	'VERSION_FROM'	=>	'XPlusX.pm',
	'XSPROTOARG'	=>	'-noprototypes'
);

-------------------------------------------------------

Rudi Sherry
487 South 21 Street
San Jose, CA   95116
+1 408 993 1235
rudi_sherry@loftsoft.com



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-modules-request@macperl.org