Re: Variable Initialization
Posted in 1998
}> I am facing a peculiar problem in one of my esql/c program. }> The program has in the EXEC BEGIN & EXEC END SECTION around 100 fields. }> one of the stmt is double qty_a, global_seq=1, global_ctr; }> }> While compiling its gives me an error }> Error -33040: Object 'global_ctr' was not declared. }> }> But when i removed '=1' from the statement it works. I tried using the }> same in one of test programs but it works. Can somebody tell me }> what the -33040 means. } }I think that the ESQL/C compiler has a very limited understanding of }initializers, and it assumes that anything after the = up to the semicolon }is initializer. If there are syntax errors in the initializer, the C }compiler will diagnose them. However, that also means that you can't }define variables after an initializer and before the next semicolon. } }Use: } } double qty_a; } double global_seq = 1; } double global_ctr; } }This allows you to apply a comment to each variable as well, and is }generally good practice. In this case, good practice is being forced upon }you, though you could, I suppose, write: } } double qty_a, global_ctr, global_seq = 1; } }I don't like it, and it doesn't generalize well -- for example, it doesn't }work if both global_* variables need to be initialized. } }Yours, }Jonathan Leffler (johnl@informix.com) #include <witticism.h> } } But Jonathan, as i wrote that the same stmt i tried to use in one of my test programs it works fine. And it was the only declaration part. It dosen't stop my work , still, just wondering. Regards, Praveen Mohanan. ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com