Re: Informix C-compiler Version does not initialize variables?
Posted in 1995
Fix your code to initialize your variables. The p-code compiler does that for you -- arguably this is a bug, because the C compiler definitely doesn't. This is probably the biggest unresolvable difference between the p-code and c-code run-time systems. > There is something wrong here because this code worked on c4gl > version 4 4gl on AT&T Unix SysV3.2 with version 4 SE. Pure coincidence -- there just happened to be a zero byte at the correct location. You were unbelievably lucky. Well, maybe not unbelievably, but definitely lucky. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> }From: john@gagme.wwa.com (pinoy_ako) }Date: 10 Mar 1995 01:29:36 -0600 }X-Informix-List-Id: <news.12108> } } We've go a program fragment like this: (clipped to minimum so } syntax isn't correct) } } FUNCTION hello(var1, var2, var3) } ... } DEFINE var3 like sometable.somecol } . } IF var3 IS NULL THEN } # do this thing } ELSE } # do another thing } END IF } } The function is called like this: } } CALL hello(param1, param2, param3) } } The problem occurs when param3 is not set to any value (only defined } like this 'DEFINE param3 CHAR(5)', no param3 = "" or initialize param3 } to null or param3 = "value"). THe program goes into the 'do other } thing' part instead of the 'do this thing'. I tried adding this code } to the function hello, above the IF statement so that I can trace } the variable var3 is being set to: } } ERROR "this is var3: ", var3 } } It showed me the following everytime I ran it: } } this is var3: >`@ } } There is something wrong here because this code worked on c4gl version } 4 4gl on AT&T Unix SysV3.2 with version 4 SE. Now that we have version } 4.12 4gl, C-compiler version on SCO unix 3.2.4 with 5.02 SE, it just } doesn't initialize the variable correctly. Can any one suggest a } solution? I can't just initialize var3 to NULL because param3 might } have a value. This is what I have already tried (but failed)