The documentation on perlxs seems to say that by designating a parameter "OUTPUT:", its value may be changed in the called C function and even though it is not a traditional return value, the corresponding variable in the calling Perl script will contain the new value.
I am passing a scalar through a Perl extension to a C function, where (as an integer) it is changed. When control returns to the Perl script, the value is the same as it was before the function was called. I just can't seem to get this to work.
.XS file:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <TestInclude.h>
MODULE = TEST PACKAGE = TEST
void
C_function(iReturn)
int iReturn
OUTPUT:
iReturn
C function:
#include "TestInclude.h"
void C_function(int iReturn)
{
iReturn = 5;
}
.H prototype:
void C_function(int iReturn);
.PM file:
package TEST;
require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(C_function);
bootstrap TEST;
1;
Test Script:
use TEST;
$Code = 25;
C_function($Code);
printf("Return Code: %d\n", $Code);
Please help. Thanks!!
-Tim Farnsworth
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.