How to automatically initialize simple variables with IBM Informix 4GL C-code

Technote (troubleshooting)


Problem(Abstract)

With IBM Informix 4GL RDS (P-code), simple variables are automatically initialized. To ensure that IBM Informix 4GL C-code behaves similarly, a compilation flag was introduced with IBM Informix 4GL version 7.50.xC6 to likewise automatically initialize simple variables (integer, char, etc.).

Symptom

With IBM Informix 4GL C-code, variables may display random values if not explicitly initialized.


Cause

The cause of the problem is that IBM Informix 4GL C-code does not automatically initialize simple variables.

Environment

Unix

Diagnosing the problem

Here is an example of a program that displays 2 integer variables that are not explicitly initialized. The variables have not been assigned any values. As you can see, the variables contain random numbers:


-- test.4gl --
MAIN

call dsply_count(10)

END MAIN

FUNCTION dsply_count(sl_secs)

DEFINE sl_secs INTEGER
DEFINE cnt INTEGER
DEFINE l_cnt INTEGER

LET l_cnt = l_cnt + cnt

DISPLAY l_cnt
DISPLAY cnt

END FUNCTION

% c4gl test.4gl -o test

% ./test
268435441
268435456


Resolving the problem

To resolve this issue, simply use the compilation flag '-initvar' when compiling your 4GL source code:

% c4gl -initvar test.4gl -o test


% ./test
0
0


Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

Informix Tools
Informix 4GL

Software version:

7.5

Operating system(s):

AIX, HP-UX, Linux, Solaris

Software edition:

Compiler, Developer

Reference #:

1632444

Modified date:

2013-03-27

Translate my page

Machine Translation

Content navigation