Search code examples
fastcgicobolstdio

fcgi_stdio.h and behaviour change from stdio.h


While discussing OpenCOBOL being utilized for FastCGI, I posted that replacing

#include <stdio.h>

with

#include <fcgi_stdio.h>

should exhibit no behaviour change for the vast majority of programs that don't care to call

FCGI_Accept()  

Did I lie? Are there issues to consider? I'll admit to having not gone over sources yet, only docs from the website.

EDIT: 2013-03-08 I've done some experiments, and the statement is proving positive, but lack sufficient evidence to advertise the statement as true. I'd still appreciate any insider information.


Solution

  • As fcgi_stdio.h is redefining many stdio symbols to its own set of FCGI_* symbols, there will with certanity be some differences. Fastcgi also offers the possibility to #define NO_FCGI_DEFINES though, which lets you use both sets - although you'd have to be explicitly specifying the FCGI_ prefix.

    I was just thinking about adding a way to determine which set is to use at runtime to be able to use the same binaries online and from cli, but thinking further about it I'll rather go with two make targets.

    Also, compiling with libfcgi-dev v2.4.0 I seem to run into blank output in conjunction with -ldl / dlopen() although both binaries link to the same libfcgi.so.0...

    --

    tl;dr if you want to use dlopen() and see the output on stdout/stderr, don't #include <fcgi_stdio.h> (without defining NO_FCGI_DEFINES)