[GRASS-dev] [GRASS GIS] #949: strings.h error when compiling recent versions of nviz

#949: strings.h error when compiling recent versions of nviz
-----------------------------------------------+----------------------------
Reporter: jkaplan | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: NVIZ | Version: svn-develbranch6
Keywords: grass6_wxnviz.i, strcasecmp, fink | Platform: MacOSX
      Cpu: OSX/Intel |
-----------------------------------------------+----------------------------
Hello GRASS developers,

When trying to compile recent versions of GRASS (v.6 development branch or
GRASS 7) I encountered an error during compilation of nviz related to the
function 'strcasecmp' which seems to be included through several layers of
the wxgtk libraries. Please see the command line output below.

{{{
admin@Abies:~/Downloads/grass6/grass6_devel/gui/wxpython/nviz > make
python setup.py build_ext --swig=/sw/bin/swig --swig-opts=-c++ --build-
lib=OBJ.i386-apple-darwin10.2.0 --build-temp=OBJ.i386-apple-darwin10.2.0
running build_ext
building '_grass6_wxnviz' extension
swigging grass6_wxnviz.i to grass6_wxnviz_wrap.cpp
/sw/bin/swig -python -c++ -o grass6_wxnviz_wrap.cpp grass6_wxnviz.i
gcc -fno-strict-aliasing -mno-fused-madd -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -DPACKAGE="grasslibs" -D_FILE_OFFSET_BITS=64
-D_LARGE_FILES -D__WXGTK__
-I/Users/admin/Downloads/grass6/grass6_devel/dist.i386-apple-
darwin10.2.0/include
-I/Library/Frameworks/GDAL.framework/Versions/1.6/Headers
-I/sw/lib/wx/include/gtk2-unicode-release-2.8 -I/sw/include/wx-2.8
-I/usr/X11/include -I/usr/X11R6/include -I/sw/include/python2.5 -c
grass6_wxnviz_wrap.cpp -o OBJ.i386-apple-darwin10.2.0/grass6_wxnviz_wrap.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for
C/ObjC but not for C++
In file included from /sw/include/wx-2.8/wx/memory.h:16,
                  from /sw/include/wx-2.8/wx/object.h:20,
                  from /sw/include/wx-2.8/wx/wx.h:16,
                  from nviz.h:23,
                  from grass6_wxnviz_wrap.cpp:2612:
/sw/include/wx-2.8/wx/string.h: In function 'int Stricmp(const char*,
const char*)':
/sw/include/wx-2.8/wx/string.h:141: error: 'strcasecmp' was not declared
in this scope
error: command 'gcc' failed with exit status 1
make: *** [OBJ.i386-apple-darwin10.2.0/_grass6_wxnviz.so] Error 1
}}}

----

I am not experienced enough of a programmer to know the "right" way to
solve this problem, but I was able to make a workaround by modifying the
file grass6_devel/gui/wxpython/nviz/grass6_wxnviz.i to include the
statement #include <strings.h>

The first lines of grass6_wxnviz.i in my patched version (which does
compile) look like this:

{{{
/* File: nviz.i */

%module grass6_wxnviz
%{
#include <strings.h>
#include "nviz.h"
#include <grass/gsurf.h>
#include <grass/gstypes.h>
#undef check
%}
}}}
etc...

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/949&gt;
GRASS GIS <http://grass.osgeo.org>

#949: strings.h error when compiling recent versions of nviz
----------------------+-----------------------------------------------------
  Reporter: jkaplan | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: NVIZ | Version: svn-develbranch6
Resolution: | Keywords: grass6_wxnviz.i, strcasecmp, fink
  Platform: MacOSX | Cpu: OSX/Intel
----------------------+-----------------------------------------------------
Comment (by glynn):

Replying to [ticket:949 jkaplan]:

> When trying to compile recent versions of GRASS (v.6 development branch
or GRASS 7) I encountered an error during compilation of nviz related to
the function 'strcasecmp' which seems to be included through several
layers of the wxgtk libraries. Please see the command line output below.
>
{{{
> /sw/include/wx-2.8/wx/string.h: In function 'int Stricmp(const char*,
const char*)':
> /sw/include/wx-2.8/wx/string.h:141: error: 'strcasecmp' was not declared
in this scope
}}}

This looks like a bug in wxWidgets. strcasecmp() isn't an ANSI C function,
so it detects if it's available and provides its own version if it isn't.
It appears to be getting the detection wrong.

> I am not experienced enough of a programmer to know the "right" way to
solve this problem, but I was able to make a workaround by modifying the
file grass6_devel/gui/wxpython/nviz/grass6_wxnviz.i to include the
statement #include <strings.h>

<strings.h> isn't portable.

The <wx/string.h> header includes <strings.h> if it's available and
required:

{{{
#ifdef HAVE_STRCASECMP_IN_STRINGS_H
     #include <strings.h> // for strcasecmp()
#endif // HAVE_STRCASECMP_IN_STRINGS_H
}}}

For whatever reason, the test appears to be incorrect, i.e. it's not
including it even though it's required.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/949#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#949: strings.h error when compiling recent versions of nviz
----------------------+-----------------------------------------------------
  Reporter: jkaplan | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 6.4.0
Component: NVIZ | Version: svn-develbranch6
Resolution: wontfix | Keywords: grass6_wxnviz.i, strcasecmp, fink
  Platform: MacOSX | Cpu: OSX/Intel
----------------------+-----------------------------------------------------
Changes (by martinl):

  * status: new => closed
  * resolution: => wontfix

Comment:

In GRASS 7.0 and 6.5 has been wxNviz C++ component replaced by Python
version. Closing this ticket as wontfix. Martin

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/949#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>