|
204 | 204 | my $filters_scn = 'Source Filters';
|
205 | 205 | my $floating_scn = 'Floating point';
|
206 | 206 | my $genconfig_scn = 'General Configuration';
|
| 207 | +my $global_definitions_scn = 'Declaration and Initialization of Globals'; |
207 | 208 | my $globals_scn = 'Global Variables';
|
208 | 209 | my $GV_scn = 'GV Handling and Stashes';
|
209 | 210 | my $hook_scn = 'Hook manipulation';
|
|
379 | 380 | =back
|
380 | 381 | EOT
|
381 | 382 | },
|
| 383 | + $global_definitions_scn => { |
| 384 | + header => <<~'EOT', |
| 385 | + Global variables are defined and initialized in one place, but |
| 386 | + referred to from multiple files. They need to be declared and any |
| 387 | + initialization done in that one place, but declarations made for |
| 388 | + them in each file that may refer to them. Note that there is no |
| 389 | + harm in declaring a global and not using it. |
| 390 | +
|
| 391 | + Perl has a mechanism that allows both purposes to be served while |
| 392 | + minimizing code duplication. Most files will include the file |
| 393 | + F<EXTERN.h>; the few files that do the actual definitions instead |
| 394 | + include the file F<INTERN.h>. These header files #define the same |
| 395 | + macros, but with different definitions. In F<EXTERN.h>, the |
| 396 | + macros expand to declarations of the globals as external to the |
| 397 | + file. In F<INTERN.h> they actually cause the space to be |
| 398 | + allocated and possibly initialized. |
| 399 | +
|
| 400 | + This section documents these macros. F<perl.h> has many uses that |
| 401 | + can serve as paradigms for you. |
| 402 | + EOT |
| 403 | + may_be_empty_in_perlapi => 1, |
| 404 | + }, |
382 | 405 | $globals_scn => {},
|
383 | 406 | $GV_scn => {},
|
384 | 407 | $hook_scn => {},
|
|
481 | 504 | 'gv.c' => $GV_scn,
|
482 | 505 | 'gv.h' => $GV_scn,
|
483 | 506 | 'hv.h' => $HV_scn,
|
| 507 | + 'INTERN.h' => $global_definitions_scn, |
484 | 508 | 'locale.c' => $locale_scn,
|
485 | 509 | 'malloc.c' => $memory_scn,
|
486 | 510 | 'numeric.c' => $numeric_scn,
|
|
0 commit comments