04-02-2008
From PerlFAQ .....
Quote:
Where can I learn about linking C with Perl?
If you want to call C from Perl, start with perlxstut, moving on to perlxs, xsubpp, and perlguts. If you want to call Perl from C, then read perlembed, perlcall, and perlguts. Don't forget that you can learn a lot from looking at how the authors of existing extension modules wrote their code and solved their problems.
You might not need all the power of XS. The Inline::C module lets you put C code directly in your Perl source. It handles all the magic to make it work. You still have to learn at least some of the perl API but you won't have to deal with the complexity of the XS support files.
10 More Discussions You Might Find Interesting
1. Programming
hi,
I just started to work on unix,
I was wondering if it is possible to call a c++ function from a script.
now, i don't mean starting a program, i mean dynamicaly calling a funtion (like working with a dll)
thanks (3 Replies)
Discussion started by: Lebamb
3 Replies
2. Shell Programming and Scripting
Hi folks,
I'm just running through an oreilly korn shell book but have witnessed an output difference on my own unix machine and the output provided in the book. Can anyone help?
create a script called ascript as follows:
function afunc {
print in function $0: $1 $2
var1="in... (16 Replies)
Discussion started by: beckett
16 Replies
3. Shell Programming and Scripting
Hi,
Can we define a function say func1 in a script 1.sh and call this function from another script say 2.sh by passing an argument :confused: (2 Replies)
Discussion started by: jisha
2 Replies
4. Shell Programming and Scripting
:confused:Hi ,
I have a script as shown below:
rpttxt()
{
name="$*"
awk '/'"${name}"'/ {print $2 $3"=" $4}' file.txt
}
xx = rpttxt "COL_HEAD_1"
awk 'BEGIN {printf("%36s \n ","'"$xx"'")}'
rpttxt() is a function..I want to store the final result of this function in... (3 Replies)
Discussion started by: jisha
3 Replies
5. UNIX for Dummies Questions & Answers
i have a function defined in one ksh (ksh 1)
i want to use that function in another ksh (ksh 2)
i am using
. $<directoryname>/<ksh name>
i am calling the function defined in ksh 1 in ksh 2
i want the returnstatus from the above operation
but it is not executing the function
what i... (1 Reply)
Discussion started by: trichyselva
1 Replies
6. Shell Programming and Scripting
Hi,
I have searched the forum for the query, But i didnt find an exact answer.
I have a script(1.sh) and a c program(sample.c)
sample.c contains many function definitions.( run(), find(), add() etc).
I want to call functions in sample.c from 1.sh and use the return value in 1.sh... (3 Replies)
Discussion started by: jisha
3 Replies
7. Shell Programming and Scripting
This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord
but only one record is getting wrote in DB.... Please advise ASAP...:confused:
function InsertFtg
{
FTGSTR=""
echo "Saurabh is GREAT $#"
let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies
8. Shell Programming and Scripting
Hi all,
This is the first time i am using expect.
I am trying to call a function with in the shell script. The function will shh to a new server and will pass the password using expect and send. I need help in calling the fuction i am getting follaowing errors...
here the script
... (8 Replies)
Discussion started by: firestar
8 Replies
9. Shell Programming and Scripting
I would like to call functions from another bash script. How can I do it? Some code More code (11 Replies)
Discussion started by: kristinu
11 Replies
10. Shell Programming and Scripting
Hi
I need to call a function in database and update the return value of that function with a value in csv file.
test.csv
1,2,3,,5,,,8,9,10
1,2,3,4,5,,,8,9,10
1,2,3,,,,,8,9,10In the above file I want to replace column 2 with a value extracted from database
like (select student_id from... (3 Replies)
Discussion started by: kev94
3 Replies
LEARN ABOUT MOJAVE
xsubpp
XSUBPP(1) Perl Programmers Reference Guide XSUBPP(1)
NAME
xsubpp - compiler to convert Perl XS code into C code
SYNOPSIS
xsubpp [-v] [-except] [-s pattern] [-prototypes] [-noversioncheck] [-nolinenumbers] [-nooptimize] [-typemap typemap] [-output filename]...
file.xs
DESCRIPTION
This compiler is typically run by the makefiles created by ExtUtils::MakeMaker or by Module::Build or other Perl module build tools.
xsubpp will compile XS code into C code by embedding the constructs necessary to let C functions manipulate Perl values and creates the
glue necessary to let Perl access those functions. The compiler uses typemaps to determine how to map C function parameters and variables
to Perl values.
The compiler will search for typemap files called typemap. It will use the following search path to find default typemaps, with the
rightmost typemap taking precedence.
../../../typemap:../../typemap:../typemap:typemap
It will also use a default typemap installed as "ExtUtils::typemap".
OPTIONS
Note that the "XSOPT" MakeMaker option may be used to add these options to any makefiles generated by MakeMaker.
-hiertype
Retains '::' in type names so that C++ hierarchical types can be mapped.
-except
Adds exception handling stubs to the C code.
-typemap typemap
Indicates that a user-supplied typemap should take precedence over the default typemaps. This option may be used multiple times, with
the last typemap having the highest precedence.
-output filename
Specifies the name of the output file to generate. If no file is specified, output will be written to standard output.
-v Prints the xsubpp version number to standard output, then exits.
-prototypes
By default xsubpp will not automatically generate prototype code for all xsubs. This flag will enable prototypes.
-noversioncheck
Disables the run time test that determines if the object file (derived from the ".xs" file) and the ".pm" files have the same version
number.
-nolinenumbers
Prevents the inclusion of '#line' directives in the output.
-nooptimize
Disables certain optimizations. The only optimization that is currently affected is the use of targets by the output C code (see
perlguts). This may significantly slow down the generated code, but this is the way xsubpp of 5.005 and earlier operated.
-noinout
Disable recognition of "IN", "OUT_LIST" and "INOUT_LIST" declarations.
-noargtypes
Disable recognition of ANSI-like descriptions of function signature.
-C++ Currently doesn't do anything at all. This flag has been a no-op for many versions of perl, at least as far back as perl5.003_07.
It's allowed here for backwards compatibility.
ENVIRONMENT
No environment variables are used.
AUTHOR
Originally by Larry Wall. Turned into the "ExtUtils::ParseXS" module by Ken Williams.
MODIFICATION HISTORY
See the file Changes.
SEE ALSO
perl(1), perlxs(1), perlxstut(1), ExtUtils::ParseXS
perl v5.18.2 2018-08-17 XSUBPP(1)