# Different ways to collect an extension's functions.

- Thread: https://externals.io/message/48768
- Original archive: https://news-web.php.net/php.internals/48768
- Started by Richard Quadling on 2010-06-14T10:38:51+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #48768 — Richard Quadling — 2010-06-14T10:38:51+00:00

URL: https://externals.io/message/48768#48768

Hi.

I'm looking into bug#52079 (missing lcfirst function from function index).

The cause of the bug is that the genfunclist / genfuncindex scripts
haven't been run in a while.

Whilst running them and fixing a small issue with ereg => preg, I
notice that in the results of genfunclist, there are 3 different ways
to collect an extensions functions ...

1) The majority use const (79 in total).

# const zend_function_entry apache_functions[] = {
# const zend_function_entry apache_functions[] = {
# const zend_function_entry basic_functions[] = {
# const zend_function_entry bcmath_functions[] = {
# const zend_function_entry birdstep_functions[] = {
...
# const zend_function_entry xsl_functions[] = {
# const zend_function_entry zend_funcs_aggregate[] = {
# const zend_function_entry zend_funcs_arrayaccess[] = {
# const zend_function_entry zend_funcs_iterator[] = {
# const zend_function_entry zend_funcs_serializable[] = {


2) The following use static.

# static zend_function_entry disabled_function[] = {
# static zend_function_entry mysqlnd_functions[] = {
# static zend_function_entry php_sqlite3_class_methods[] = {
# static zend_function_entry php_sqlite3_result_class_methods[] = {
# static zend_function_entry php_sqlite3_stmt_class_methods[] = {
# static zend_function_entry spl_funcs_SplFixedArray[] = {


3) The following don't use const or static.

# zend_function_entry enchant_functions[] = {
# zend_function_entry fileinfo_functions[] = {
# zend_function_entry intl_functions[] = {
# zend_function_entry litespeed_functions[] = {
# zend_function_entry phar_exception_methods[] = {
# zend_function_entry phar_functions[] = {
# zend_function_entry php_archive_methods[] = {
# zend_function_entry php_entry_methods[] = {
# zend_function_entry php_oci_functions[] = {


Regards,

Richard.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

---

## #48769 — Melanie Rhianna Lewis — 2010-06-14T10:56:57+00:00

URL: https://externals.io/message/48768#48769 · In reply to: #48768

My feeling is that they should all be static consts unless explicitly accessed outside of the object module or changed.    Since typically they're a list of function/method entries only accessed by a class or zend_module_entry that is really the case.  Without the static we're polluting the name space.

Melanie



> Hi.
> 
> I'm looking into bug#52079 (missing lcfirst function from function index).
> 
> The cause of the bug is that the genfunclist / genfuncindex scripts
> haven't been run in a while.
> 
> Whilst running them and fixing a small issue with ereg => preg, I
> notice that in the results of genfunclist, there are 3 different ways
> to collect an extensions functions ...
> 
> 1) The majority use const (79 in total).
> 
> # const zend_function_entry apache_functions[] = {
> # const zend_function_entry apache_functions[] = {
> # const zend_function_entry basic_functions[] = {
> # const zend_function_entry bcmath_functions[] = {
> # const zend_function_entry birdstep_functions[] = {
> ...
> # const zend_function_entry xsl_functions[] = {
> # const zend_function_entry zend_funcs_aggregate[] = {
> # const zend_function_entry zend_funcs_arrayaccess[] = {
> # const zend_function_entry zend_funcs_iterator[] = {
> # const zend_function_entry zend_funcs_serializable[] = {
> 
> 
> 2) The following use static.
> 
> # static zend_function_entry disabled_function[] = {
> # static zend_function_entry mysqlnd_functions[] = {
> # static zend_function_entry php_sqlite3_class_methods[] = {
> # static zend_function_entry php_sqlite3_result_class_methods[] = {
> # static zend_function_entry php_sqlite3_stmt_class_methods[] = {
> # static zend_function_entry spl_funcs_SplFixedArray[] = {
> 
> 
> 3) The following don't use const or static.
> 
> # zend_function_entry enchant_functions[] = {
> # zend_function_entry fileinfo_functions[] = {
> # zend_function_entry intl_functions[] = {
> # zend_function_entry litespeed_functions[] = {
> # zend_function_entry phar_exception_methods[] = {
> # zend_function_entry phar_functions[] = {
> # zend_function_entry php_archive_methods[] = {
> # zend_function_entry php_entry_methods[] = {
> # zend_function_entry php_oci_functions[] = {
> 
> 
> Regards,
> 
> Richard.
> 
> -- 
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling

---

## #48770 — Gustavo Lopes — 2010-06-14T11:28:30+00:00

URL: https://externals.io/message/48768#48770 · In reply to: #48769

On Mon, 14 Jun 2010 11:56:57 +0100, Melanie Rhianna Lewis
<cyberspice@php.net> wrote:

> My feeling is that they should all be static consts unless explicitly  
> accessed outside of the object module or changed.    Since typically  
> they're a list of function/method entries only accessed by a class or  
> zend_module_entry that is really the case.  Without the static we're  
> polluting the name space.
>

The static keyword is unnecessary, const already makes the variable have  
internal linkage by default.

-- 
Gustavo Lopes

---

## #48774 — Melanie Rhianna Lewis — 2010-06-14T13:32:25+00:00

URL: https://externals.io/message/48768#48774 · In reply to: #48770

I know the ANSI C standard pretty well but I don't remember that at all so rather than just accepting it I checked it on my Mac using a small example.  Compiler details are below:

kring:Development melanie$ gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5657)

In my example static const did have internal linkage, const on its own in the global scope did not.  You still need static.

Melanie




> On Mon, 14 Jun 2010 11:56:57 +0100, Melanie Rhianna Lewis
> <cyberspice@php.net> wrote:
> 
> > […]
> 
> The static keyword is unnecessary, const already makes the variable have internal linkage by default.
> 
> -- 
> Gustavo Lopes

---

## #48775 — Patrick ALLAERT — 2010-06-14T14:01:38+00:00

URL: https://externals.io/message/48768#48775 · In reply to: #48774

2010/6/14 Melanie Rhianna Lewis <cyberspice@php.net>:
> I know the ANSI C standard pretty well but I don't remember that at all so rather than just accepting it I checked it on my Mac using a small example.  Compiler details are below:
>
> kring:Development melanie$ gcc --version
> i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5657)
>
> In my example static const did have internal linkage, const on its own in the global scope did not.  You still need static.

Right, "const" is not similar to "static const"!

+1 for static consts for all of them

Patrick

> Melanie
>
>
> 
>
> > […]

---

## #48776 — Gustavo Lopes — 2010-06-14T14:12:28+00:00

URL: https://externals.io/message/48768#48776 · In reply to: #48774

On Mon, 14 Jun 2010 14:32:25 +0100, Melanie Rhianna Lewis  
<cyberspice@php.net> wrote:

> I know the ANSI C standard pretty well but I don't remember that at all  
> so rather than just accepting it I checked it on my Mac using a small  
> example.  Compiler details are below:
>
> kring:Development melanie$ gcc --version
> i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5657)
>
> In my example static const did have internal linkage, const on its own  
> in the global scope did not.  You still need static.
>

You're right. I'd checked it here:

http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/as400clr16.htm

and some other place, but at least the C99 standard says otherwise.

-- 
Gustavo Lopes
