The C file (mylib.c):#include <stdio.h> void my_puts(FILE*);
Now, build the library (libmylib.a):#include <stdio.h> void my_puts(FILE * stream) { fputs("hello from libmylib", stream); }
The perl script that accesses the function in libmylib.a:C:\_32\C>gcc -c mylib.c C:\_32\C>ar cru libmylib.a mylib.o
Ok ... so I've got this library (libmylib.a) that was built using mylib.h and mylib.c. For the purposes of this exercise, that (3rd party) library is to be considered non-modifiable. Of course, if it's doing something sinful, please let me know. And I've got an Inline::C script that's accessing the one and only function that's in libmylib.ause warnings; use strict; use Inline C => Config => INC => '-IC:/_32/C', LIBS => '-LC:/_32/C -lmylib', BUILD_NOISY => 1; use Inline C => <<'EOC'; #include <mylib.h> void foo(FILE * x) { my_puts(x); fflush(x); } EOC $| = 1; for(1 .. 2) { foo(*stdout); print "\nhello from perl\n"; } for(1 .. 2) { foo(*stderr); print "\nhello from perl\n"; }
That's all well and good, and the exact output I'm wanting to see. But if I comment out the line that turns the autoflush on I get the following garbled output:hello from libmylib hello from perl hello from libmylib hello from perl hello from libmylib hello from perl hello from libmylib hello from perl
I simply do not see why the output should vary in any way, dependent upon whether autoflush is on or off. As I understand it, perl's autoflush will have no effect on the C buffers ... and, since the perl print() statements terminate with a "\n", autoflush should have no effect on the perl buffers either.hello from libmylib hello from perl hello from libmylibhello from libmylibhello from libmylib hello from perl hello from perl hello from perl
In reply to Really, really suffering from buffering by syphilis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |