Hullo all,
I'm trying to embed some C code in my perl stuff. However, I seem to
be running into issues such as "Bus Error", segfaults and undefined
subroutines.
The error i'm getting with the code as it currently stands is...
Undefined subroutine &Geo::GeoCoder::UTM2WGS84 called at /Users/
xxxxxx/code/perl/lib/Geo/GeoCoder.pm line 416.
Here's what I have - it's a bit abbreviated as the entire code's
really long...
---
use Inline (Config => BUILD_NOISY => 1, CLEAN_AFTER_BUILD =>1 );
use Inline C =><<END_OF_C_CODE;
.....
void UTM2WGS84(long x, long y, double cZone, double* lat, double* lon )
{
// double* lat;
// double* lon;
x += UTM_UBI_OFFX;
y += UTM_UBI_OFFY;
UTM2ED50(x, y, cZone, lat, lon);
ED502WGS84(lat, lon, -1.0);
printf( "lat before return - %f", lat );
x = lat;
y = lon;
return 1;
// Segfaults when the below is uncommented...
// Inline_Stack_Vars;
// Inline_Stack_Reset;
// Inline_Stack_Push(sv_2mortal(newSViv(lat)));
// Inline_Stack_Push(sv_2mortal(newSViv(lon)));
// Inline_Stack_Done;
}
END_OF_C_CODE
my $lat_trov = '2099496';
my $long_trov = '1410988';
my $rdLat = "";
my $rdLon = "";
print "here\n";
print UTM2WGS84($lat_trov, $long_trov, '6.1', $rdLat, $rdLon);
print $lat_trov,"\n";
print $long_trov,"\n";
----
The original C code that calls the above C function was...
---
double rdLat;
double rdLon;
long lX = atol( argv[1] );
long lY = atol( argv[2] );
UTM2WGS84(lX , lY, 6.1, &rdLat, &rdLon );
---
Thoughts? TIA!
Y.