Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22343 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58148 invoked by uid 1010); 12 Mar 2006 06:13:08 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 58132 invoked from network); 12 Mar 2006 06:13:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2006 06:13:08 -0000 X-Host-Fingerprint: 69.12.155.130 69-12-155-130.dsl.static.sonic.net Linux 2.4/2.6 Received: from ([69.12.155.130:4663] helo=pigeon.alphaweb.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 4F/4E-21161-3FBB3144 for ; Sun, 12 Mar 2006 01:13:08 -0500 Received: from localhost ([127.0.0.1] helo=stumpy) by pigeon.alphaweb.net with smtp (Exim 4.10) id 1FIJGQ-00024K-00; Sat, 11 Mar 2006 21:37:10 -0800 Message-ID: <001001c6459c$771a60f0$7d051fac@stumpy> To: "\"Andrew Mather \(BT Std\)\"" Cc: References: <200603112311.19732.an.dromeda@btconnect.com> Date: Sat, 11 Mar 2006 22:15:42 -0800 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Subject: Re: Separating C++ zend object creation code from module code From: pollita@php.net ("Sara Golemon") > The nuance of cross-referencing these calls between two .cpp files (listed > in > config.m4, and so compiled into distinct .o files), eludes me. > > It's a c/cpp grammar issue, I guess, but one I've never had to deal with > till > now. > Quick Lesson: static: Symbols (functions, variables, etc...) declared static are not exported. This means that no other object (source file) has any way of knowing where these symbols are located and thus cannot call them. When a symbol is known not to be used outside of a given source file, it's given the static modifier to avoid polluting the process' symbol space with uneccesary references. It also avoids namespace collisions for more commonly named methods. extern: Typically used in header files with function prototype declarations. It allows one object file to be aware of the prototype and calling semantics for a function in another object file. For example: header.h extern foo(void); extern bar(void); file1.c #include "header.h" void foo(void) { /* do whatever */ } static void local_func(void) { bar(); } int main(int argc, char *argv[]) { local_func(); } file2.c #include "header.h" void bar(void) { foo(); } Same idea for .cpp of course... There are some other things to keep in mind when interfacing between C and C++ (calling semantics) or when developing DLLs for windows (linkage export semantics), but you're most likely not going to have to worry about these as the PHP extension magic pretty much covers this for you. -Sara