[GRASS-dev] lib/vector/Vlib/field.c: Assumes `HAVE_GDAL'

  Currently, GRASS doesn't compile well --without-gdal, since the
  code in `field.c' seems to assume that GDAL is available.

  The following patch seems to fix the issue. Unless there'll be
  objections, I'm going to commit it to the trunk.

--- field.c (revision 36440)
+++ field.c (working copy)
@@ -29,7 +29,9 @@
#include <grass/dbmi.h>
#include <grass/Vect.h>

+#ifdef HAVE_GDAL
#include <gdal_version.h> /* needed for FID detection */
+#endif /* HAVE_GDAL */

/*!
    \brief Create and init new dblinks ctructure
@@ -443,7 +445,11 @@

     G_debug(3, "Searching for FID column in OGR DB");
     if (Map->format == GV_FORMAT_OGR) {

+#ifndef HAVE_GDAL
+ G_fatal_error(_("The support for OGR vector maps wasn't"
+ " compiled in."));
+#else
#if GDAL_VERSION_NUM > 1320 /* seems to be fixed after 1320 release */
   int layer, nLayers;
   OGRDataSourceH Ogr_ds;
@@ -596,6 +601,7 @@
   }
#endif /* GDAL_VERSION_NUM > 1320 */
   return (1);
+#endif /* HAVE_GDAL */
     }
     else if (Map->format != GV_FORMAT_NATIVE) {
   G_fatal_error(_("Don't know how to read links for format %d"),

--
FSF associate member #7257

On Sun, Mar 22, 2009 at 1:31 PM, Ivan Shmakov <oneingray@gmail.com> wrote:

   Currently, GRASS doesn&#39;t compile well \-\-without\-gdal, since the
   code in \`field\.c&#39; seems to assume that GDAL is available\.

   The following patch seems to fix the issue\.  Unless there&#39;ll be
   objections, I&#39;m going to commit it to the trunk\.

--- field.c (revision 36440)
+++ field.c (working copy)
@@ -29,7 +29,9 @@
#include <grass/dbmi.h>
#include <grass/Vect.h>

+#ifdef HAVE_GDAL
#include <gdal_version.h> /* needed for FID detection */
+#endif /* HAVE_GDAL */

/*!
\brief Create and init new dblinks ctructure
@@ -443,7 +445,11 @@

G\_debug\(3, &quot;Searching for FID column in OGR DB&quot;\);
if \(Map\-&gt;format == GV\_FORMAT\_OGR\) \{

+#ifndef HAVE_GDAL
+ G_fatal_error(_("The support for OGR vector maps wasn't"
+ " compiled in."));
+#else
#if GDAL_VERSION_NUM > 1320 /* seems to be fixed after 1320 release */
int layer, nLayers;
OGRDataSourceH Ogr_ds;
@@ -596,6 +601,7 @@
}
#endif /* GDAL_VERSION_NUM > 1320 */
return (1);
+#endif /* HAVE_GDAL */
}
else if (Map->format != GV_FORMAT_NATIVE) {
G_fatal_error(_("Don't know how to read links for format %d"),

This looks good to me (untested).

Markus

Markus Neteler <neteler@osgeo.org> writes:

>> Currently, GRASS doesn't compile well --without-gdal, since the
>> code in `field.c' seems to assume that GDAL is available.

>> The following patch seems to fix the issue. Unless there'll be
>> objections, I'm going to commit it to the trunk.

>> --- field.c (revision 36440)
>> +++ field.c (working copy)
>> @@ -29,7 +29,9 @@
>> #include <grass/dbmi.h>
>> #include <grass/Vect.h>

>> +#ifdef HAVE_GDAL
>> #include <gdal_version.h> /* needed for FID detection */
>> +#endif /* HAVE_GDAL */

[...]

> This looks good to me (untested).

  At least, it compiles here (without HAVE_GDAL) fine.

  I've committed the change as r36464.

http://trac.osgeo.org/grass/changeset/36464

--
FSF associate member #7257