#1008 incorrect #define wrapping

closed
python (259)
5
2010-08-29
2009-04-09
No

I found a bug, which is reproducible in SWIG 1.3.36 and 1.3.38. Test
case is very small and easy.

--------------------
%module(directors="1") swig_bug

#define BOLTZMANN (1.380658e-23)
#define AVOGADRO (6.0221367e23)
#define RGAS (BOLTZMANN*AVOGADRO)
--------------------

This results in the following code snippet in the generated wrapper for python

----------------------------
SWIG_Python_SetConstant(d,
"BOLTZMANN",SWIG_From_double((double)((1.380658e-23))));
SWIG_Python_SetConstant(d,
"AVOGADRO",SWIG_From_double((double)((6.0221367e23))));
SWIG_Python_SetConstant(d,
"RGAS",SWIG_From_double((double)(((380658e-23 1.) *(6.0221367e23)))));
---------------------------

Bug is in the last line. As one can see, the BOLTZMANN constant was
transformed from "1.380658e-23" to "380658e-23 1.". This leads to the
"swig_bug_wrap.c:3272: error: expected ‘)’ before numeric constant"
compiler error.

Discussion

  • William Fulton

    William Fulton - 2010-08-29
    • assigned_to: nobody --> wsfulton
    • status: open --> closed
     
  • William Fulton

    William Fulton - 2010-08-29

    This was fixed in swig-1.3.40.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks