SourceForge has been redesigned. Learn more.
Close

#1365 Regression in 3.0.0: "Syntax error in input" with operator>>

None
closed
None
5
2014-04-04
2014-04-02
Ben Webb
No

SWIG 3.0.0 can no longer parse operator>> in C++ code:

test.h:
std::istream &operator<<(std::istream &in, int i) {}
std::istream &operator>>(std::istream &in, int i) {}

test.i:
%module "test"
%include "test.h"

Run with "swig -c++ test.i"

On OS X Mavericks, with the Homebrew build of SWIG 3.0.0, this gives:
test.h:2: Error: Syntax error in input(1).

With SWIG 2.0.12 I instead get the expected:
test.h:1: Warning 503: Can't wrap 'operator <<' unless renamed to a valid identifier.
test.h:2: Warning 503: Can't wrap 'operator >>' unless renamed to a valid identifier.

Discussion

  • William Fulton

    William Fulton - 2014-04-04
    • status: open --> closed
    • assigned_to: William Fulton
    • Group: -->
     
  • William Fulton

    William Fulton - 2014-04-04

    This was tested for the 3.0.0 release, but the combined lines has triggered a corner case bug. This is now fixed for 3.0.1.

    There is a workaround you may want to use until it is released, just swap the lines around:

    std::istream &operator>>(std::istream &in, int i) {}
    std::istream &operator<<(std::istream &in, int i) {}
    
     

Log in to post a comment.