Informix Error -4046: Formal declaration appeared previously for this informal function definition. The formal declaration is invalidated.
Cause and resolution
Formal declaration appeared previously for this informal function definition. The formal declaration is invalidated.
A formal declaration for this function appeared previously in this source module. At this point, a definition in the informal function syntax appears.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4046 fires when a function already has a formal (prototype-style) declaration earlier in the module, but its actual definition then uses informal function syntax — per the official guidance, this invalidates the earlier formal declaration.
- A function with an earlier formal (prototype) declaration whose definition uses informal syntax, per the official guidance — the direct, only cause.
Solutions / Resolution
- Make the function's declaration and definition consistently use either formal or informal syntax.
Examples
A formal declaration followed by an informal definition
FUNCTION save(id INTEGER) RETURNING INTEGER
FUNCTION save(id)
-- -4046: this informal definition invalidates the formal declaration above
END FUNCTION
Corrected
FUNCTION save(id INTEGER) RETURNING INTEGER
...
END FUNCTION
Diagnostic Checks
- Check every function with an earlier formal declaration, and confirm its definition also uses formal syntax.
Related Errors / Related Topics
- -4050 — "Function "name" has been used and hence declared as informal before this formal declaration." A related formal/informal declaration-ordering error, about a call preceding a formal declaration rather than a formal declaration being invalidated by an informal definition.
A function's formal declaration is invalidated by an informal-syntax definition — make both consistent.