Hi,

I've had multiple reports of problems compiling DBD::Informix 2003.03.*
and 2003.04, on both Linux and Solaris, and the problem turns out to be
in the DBI 1.34 code in Driver.xst for handling data_sources (which is
still my fault - mostly).  Newer versions of GCC (eg 3.2.1 - as found on
my machine) are mostly C-99 compliant and accept variable declarations
part way through a block of code; older versions of GCC (eg 2.9x) do not
accept this, and neither do the Sun C Compilers.  And the generated code
for data_sources from Driver.xst as found in DBI 1.34 gets a variable
declared after some executable code (thanks to Boban for sending the
Informix.c file that demonstrated the problem).

    /* Example of the problem */
    int function(void)
    {
        int i;
        i = 3;
        int j = i + 1;  /* OK in GCC 3.2.1 and C-99 - and C++ */
        return (j);
    }

The attachment is a patch for Driver.xst from DBI 1.34.  It puts the
variable declarations at the start of a block (by introducing a new
block) and annotates why.

With luck, this means that DBD::Informix v2003.03.* and v2003.04 will
compile OK with the amended template file.

-- 
Jonathan Leffler                           #include <disclaimer.h>
STSM, Informix Database Engineering, IBM Data Management
Phone: +1 650-926-6921   Fax: +1 650-926-6971   Tie-line: 630-6921
Email: [EMAIL PROTECTED]
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org
--- Driver.xst.old      2003-02-26 09:56:29.000000000 -0800
+++ Driver.xst  2003-03-06 11:10:09.586854000 -0800
@@ -50,22 +50,29 @@
 
 void
 data_sources(drh, attr = Nullsv)
-       SV *drh
-       SV *attr
-       PPCODE:
+    SV *drh
+    SV *attr
+    PPCODE:
+    {
+       /*
+       ** JL 2003-03-06: Variable declarations part way through a block
+       ** not accepted by ISO/IEC 9899:1990 compilers - a problem with
+       ** older versions of GCC (eg 2.97) on Linux platforms.
+       */
        D_imp_drh(drh);
        AV *av;
        av = dbd_dr_data_sources(drh, imp_drh, attr);
        if (av)
        {
-               int i;
-               int n = AvFILL(av)+1;
-               EXTEND(sp, n);
-               for (i = 0; i < n; ++i)
-               {
-                       PUSHs(AvARRAY(av)[i]);
-               }
+           int i;
+           int n = AvFILL(av)+1;
+           EXTEND(sp, n);
+           for (i = 0; i < n; ++i)
+           {
+               PUSHs(AvARRAY(av)[i]);
+           }
        }
+    }
 
 #endif
 

Reply via email to