Re: Using printf() in a 4gl program w/C
Posted in 1992
Path: emory!ogicse!uwm.edu!linac!att!cbnewsm!jonesie From: jonesie@cbnewsm.att.com (The Bohemian Welshman) Newsgroups: comp.databases.informix Message-ID: <1992Jan30.000533.25067@cbnewsm.att.com> Date: 30 Jan 92 00:05:33 GMT References: <1992Jan28.215456.3789@kodak.kodak.com> Organization: AT&T, Columbus, Ohio Posted: Wed Jan 29 16:05:33 1992 In article <1992Jan28.215456.3789@kodak.kodak.com> (Mitch Amiano) writes: >This may be a simple question, but are there any known problems >calling a C function which uses printf() from a 4gl program ? >My program is a 4gl executable with ESQL/C functions linked in. The >ESQL/C functions use stdio routines for i/o. Is this ok/not-ok ? [...] > The output looks like this: > > First status message. > Next status message. > Next message... Yep, I had the identical problem when using stdio. The I/O control is just not set up by the 4gl executables in the fashion you would expect. Try calling the following routine, or something like it, before using the stdio calls. (It sets the "on a NL do a CR" bit for standard out. So far no evil has befallen me, but as always, test your hacks well. You may also want to improve there error handling.) #include <termio.h> void fix_io() { struct termio arg_struct; if ( ioctl(1,TCGETA,&arg_struct) < 0) fprintf(stderr,"TCGETA error\\n"); arg_struct.c_oflag = arg_struct.c_oflag | ONLCR; if ( ioctl(1,TCSETA,&arg_struct) < 0) fprintf(stderr,"TCSETA error\\n"); } -- Chuck Jones cej@ccsitn.att.com Speaking just for me, not AT&T