Inline::C
<!--[if supportFields]><span lang=EN-US><span style='mso-element:field-begin'></span><span style='mso-spacerun:yes'></span>TOC \o "1-3" \h \z \u <span style='mso-element:field-separator'></span></span><![endif]-->Inline::C. <!--[if supportFields]><span style='color:windowtext;display:none;mso-hide:screen;text-decoration:none; text-underline:none'><span style='mso-element:field-begin'></span></span><span style='color:windowtext;display:none;mso-hide:screen;text-decoration:none; text-underline:none'> PAGEREF _Toc181016685 \h </span><span style='color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none'><span style='mso-element:field-separator'></span></span><![endif]-->1<!--[if gte mso 9]><xml> <w:data>08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003100380031003000310036003600380035000000</w:data> </xml><![endif]--><!--[if supportFields]><span style='color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none'><span style='mso-element:field-end'></span></span><![endif]-->
<!--[if supportFields]><span lang=EN-US><span style='mso-element:field-end'></span></span><![endif]-->
<!--[if !supportLists]-->1 <!--[endif]-->Name
Inline::C - Write Perl Subroutines in C
<!--[if !supportLists]-->2 <!--[endif]-->Description
Inline::C
is a module that allows you to write Perl subroutines in C.
Since version 0.30 the Inline module supports multiple programming languages and each language has its own support module. This document describes how to use Inline with the C programming language.
<!--[if !supportLists]-->3 <!--[endif]-->Usage
1) It is just a support module for using Inline.pm
with C. So the usage is always:
use Inline C => ...;
or
bind Inline C => ...;
2) An Example:
use strict;
use Inline C=> ‘DATA’;
# perl code goes here …
__DATA__
__C__
/*C code goes here …*/
<!--[if !supportLists]-->4 <!--[endif]-->Function Definitions
1) Function definition in C code which will be bound to Perl:
return-type function-name (type-name-pairs) {/*function body*/…}
2) type: int, long, double, char*, SV* (pointer to Scalar Value)(char*是字符串,SV*是数字串)
return-type: void, and Ditto
3) Notice:
Inline only looks for function definitions, not function prototypes. Definitions are the syntax directly preceeding a function body.
Inline does not scan external files, like headers. (Although other libraries can linked in, and called from C-space, only the code passed to Inline is used to create bindings.) ?
<!--[if !supportLists]-->5 <!--[endif]-->C Configuration Options
AUTO_INCLUDE
AUTOWRAP
…
<!--[if !supportLists]-->6 <!--[endif]-->C-Perl Bindings and The Inline Stack Macros
…
<!--[if !supportLists]-->7 <!--[endif]-->Writing C Subroutines
The definitions of your C functions will fall into one of the following four categories. For each category there are special considerations.
1) int Foo(int arg1, char* arg2, SV* arg3) {
2) void Foo(int arg1, char* arg2, SV* arg3) {
3) char* Foo(SV* arg1, ...) {
4) void* Foo(SV* arg1, ...) {
<!--[if !supportLists]-->8 <!--[endif]-->Examples










































Notes: 如上是一个Inline C的示例程序
<!--[if !supportLists]-->9 <!--[endif]-->Inline::C-Cookbook (More Inline::C Examples)
http://www.penguin-soft.com/penguin/man/3/Inline::C-Cookbook.html
10. 一些实例:














调用Win32,显示窗体:




















更多使用Inline::C的实例参看Inline::C-Cookbook
http://www.penguin-soft.com/penguin/man/3/Inline::C-Cookbook.html