Static and extern

C Scripting Language
Reference Manual
Version 4.4.0

<< Back  End  Next >>
 
 
INDEX
Introduction
Installation
Using the CSL executive
Language
   Comments
   Numbers
   Literals
   Var and const
      Arrays
      Initialization
      Static and extern
      Dynamic relocation
   Operators
   Statements and blocks
   Program flow
   Trace facility
   Exception handling
   Functions
   Predefined identifiers
Directives
System library
String library
Math library
Regular expression lib.
File library
Database library
Async Communication
Registry/Profile handling
Windows control
C API
C++ Class Interface
CSL links
  

Global identifiers may be prefixed by static or extern:

static var max = 100;

Static globals as max are visible only to the module they are defined in. Unlike C/C++, static's may not be defined within functions.

extern const size;

Since size is defined external there is no initializer allowed in this context. In fact you can use extern also as forward declaration for an identifier declared later in the same module. As long as the value of size is unknown you cannot use it as index when defining a global array. However you may use it to define arrays within functions:

var zz[size]; // illegal, unknown at compile time
 
var bee(var y)
{
  var kk[y][size]; // ok, allocated at runtime
} // bee

External declarations are necessary when using identifiers that are loaded at runtime (see sysLoadScript and sysLoadLibrary). Usually you will have the external definitions in a .csl file bound in by #include or #loadScript. Identifiers loaded at compile-time need no forward declaration if they are loaded before use.

  Copyright © IBK Landquart Last revision: 27.05.2002 << Back  Top  Next >>