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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to