Informix Error -4120: Declare variable "name" either external or local to module, but not both.
Cause and resolution
Declare variable "name" either external or local to module, but not both.
The specified variable has been declared or defined more than once. At least one of those times declared it with EXTERNAL, and another was a definition as a module variable (lacking either EXTERNAL or GLOBAL). Review the declarations and definitions of name, recalling that some of them might be in included files. If you intend name as a variable private to this module, give it a unique name. (You can declare a variable as EXTERNAL more than once, and you can declare it as EXTERNAL and then define it as GLOBAL. Both of these things can happen as a result of including header files, and they have well-defined meanings. But it is contradictory to have a variable that is both external and local to the module.)
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4120 fires when a variable is both declared EXTERNAL and defined as a plain module variable
(lacking EXTERNAL/GLOBAL) — per the official guidance, declaring a variable EXTERNAL
multiple times, or EXTERNAL then GLOBAL, is fine and well-defined (often via included
header files), but a variable can't be both external and local to the module at once.
- A variable declared
EXTERNALin one place and defined as a plain module variable in another, per the official guidance — the direct, only cause.
Solutions / Resolution
- Review the declarations and definitions of
name, per the official guidance, including any in included files. - If
nameis meant to be private to this module, give it a unique name, per the official guidance.
Examples
Conflicting EXTERNAL and module-local declarations
EXTERNAL max_retries INTEGER
...
DEFINE max_retries INTEGER
-- -4120: max_retries is both EXTERNAL and module-local
Corrected
EXTERNAL max_retries INTEGER
Diagnostic Checks
- Check every declaration/definition of the variable across the module and its included
files, and confirm it's consistently
EXTERNALor consistently module-local, not both.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -4120 in this set yet.
A variable is declared both EXTERNAL and as a plain module-local variable — make it
consistently one or the other, or rename the module-local copy.