2009/6/29 Solomon Gibbs <solomon.gibbs@gmail.com>

On Fri, Jun 26, 2009 at 7:20 PM, William S Fulton <wsf@fultondesigns.co.uk> wrote:

2009/6/26 Solomon Gibbs <solomon.gibbs@gmail.com>

On Thu, Jun 25, 2009 at 1:59 PM, William S Fulton <wsf@fultondesigns.co.uk> wrote:
Solomon Gibbs wrote:
I have a rather nasty struct in the code I'm wrapping. Though version 1.3.36, swig has always consumed it without complaining. However, I recently downloaded 1.3.39 and now I get a syntax error at the line corresponding to the end of the "meta_size" struct (below). The preprocess result from running swig with -E looks like more or less what I would expect.

Does anyone have any idea what has changed, or how to figure out I am doing wrong? I've tried a couple of the --debug-* options, but the parse seems to stop before they can have any effect.

Any help would be appreciated.

The following struct doesn't seem to work under 1.3.38 or 1.3.39. I haven't checked 1.3.37.

typedef struct H5O_info_t {
   unsigned long     fileno;
   haddr_t         addr;
   H5O_type_t         type;
   unsigned         rc;
   time_t        atime;
   time_t        mtime;
   time_t        ctime;
   time_t        btime;
   hsize_t         num_attrs;
   struct {
       unsigned version;
       unsigned nmesgs;
       unsigned nchunks;
       unsigned flags;
       struct {
           hsize_t total;
           hsize_t meta;
           hsize_t mesg;
           hsize_t free;
       } space;
       struct {
           uint64_t present;
           uint64_t shared;
       } mesg;
   } hdr;
   struct {
       H5_ih_info_t obj;
       H5_ih_info_t attr;
   } meta_size;
} H5O_info_t;

I don't get any error using this struct and I don't see any problems using valgrind on SWIG for this struct. I think the best thing is for you to provide the exact commandline options you are passing to SWIG and provide a complete standalone interface file that shows the problem. Also which operating system, compiler and compile options you used to compile SWIG.


The minimum module that causes the problem seems to be the struct itself. (attached, for completeness)

My swig commandline is:
/c/opt/swig/swigwin-1.3.39/swig.exe -java -package "permafrost.hdf.libhdf" -outdir "target/swig-java/permafrost/hdf/libhdf"  src/swig/H5O_info_t.i
src\swig\H5O_info_t.i(34): Error: Syntax error in input(3).

I am using the pre-build windows binaries from sourceforge; unzipped and used as-provided. But I have reason to suspect my install is misconfigured somehow anyway: If I try to run swig with -Wallkw, it fails while trying to load php.swg:

 /c/opt/swig/swigwin-1.3.39/swig.exe  -Wallkw  -java -package "permafrost.hdf.libhdf" -outdir "target/swig-java/permafrost/hdf/libhdf"  src/swig/H5O_info_t.i
c:\opt\swig\swigwin-1.3.39\Lib\php\php.swg(13): Error: Unable to find 'phpinit.swg'
c:\opt\swig\swigwin-1.3.39\Lib\php\php.swg(15): Error: Unable to find 'globalvar.i'
c:\opt\swig\swigwin-1.3.39\Lib\php\php.swg(16): Error: Unable to find 'const.i'
c:\opt\swig\swigwin-1.3.39\Lib\php\php.swg(38): Error: Unable to find 'utils.i'
c:\opt\swig\swigwin-1.3.39\Lib\php\php.swg(311): Error: Unable to find 'phpkw.swg'

Can you check that the Java examples work unmodified in the Examples\Java\class directory. There is a visual studio project in this directory for you to run and build everything (use Release build). Have you tried downloading the swigwin package again?


I ran the example you suggested. I did need to set the project environment variables for JAVA_INCLUDE and JAVA_BIN. Once those were set, everything worked okay.

I've downloaded swigwin-1.3.39 twice as well as 1.3.37 and 1.3.38. None of the last three releases appear to work on my interface. They each give the same syntax error processing the struct and they all fail trying to load the php-related files with launched with -Wallkw.

I have also tried re-downloading 1.3.36 and unzipping it in a new directory to try and rule out some sort of path issue. 1.3.36 seems to work no matter where I install it. It also accepts -Wallkw properly.
This smells like an installation/path problem. Do you simply unzip the swigwin zip file and run swig from there? Check that the library is configured correctly, like this:

C:\swig\swigwin-1.3.39>cd Examples\java\simple

C:\swig\swigwin-1.3.39\Examples\java\simple>..\..\..\swig.exe -swiglib

Then run the example in verbose mode and check the search paths are as below:

C:\swig\swigwin-1.3.39\Examples\java\simple>..\..\..\swig.exe -v -java example.i

LangSubDir: java
Search paths:
Starting language-specific parse...
Processing types...
C++ analysis...
Generating wrappers...

If all that is the same then in modify example.i demonstrating the problem using the same command line options and send the example.i here.