[Swig-user] Compatibility of SWIG 2.0.4 for GCC 4.5.2 (unordered_map)

21 views
Skip to first unread message

Lee, Si Long

unread,
Mar 13, 2012, 4:30:43 AM3/13/12
to swig...@lists.sourceforge.net

Hi,

 

                I am using SWIG 2.0.4 to generate Tcl wrapper which acts as interface to C++ code. I am using GCC compiler version 4.5.2, and ‘unordered_map’ is used in somewhere in my code. Anyway, I saw this error when compiling my *.i file with SWIG 2.0.4:

 

../QxApi/QxFilter.h:206: Error: Syntax error in input(3).

 

Content in QxFilter.h:

Line 206: static void Config(QXSTRHASH(std::vector<std::string>)& inputs, QXSTRHASH(std::vector<std::string>)& outputs);

 

#define QXSTRHASH(T) std::unordered_map<std::string, T>

 

My question is, whether SWIG 2.0.4 is fully compatible to GCC standard C++0x? if yes, please advise any trick that I can apply to avoid this kind of error. Thank you.

 

 

 

Thanks & Regards,

 

Lee Si Long

 

William S Fulton

unread,
Mar 15, 2012, 5:03:27 PM3/15/12
to Lee, Si Long, swig...@lists.sourceforge.net

The C++0x support has not been merged into the mainline SWIG releases
yet. The problem in your case is highlighted if you run SWIG -E, you'll
see the output is:

static void Config(std::unordered_map<std::string,
std::vector<std::string>>& inputs, std::unordered_map<std::string,
std::vector<std::string>>& outputs);

and the problem is '>>' introduced in C++0x. You can workaround this by
changing your macro to:

#define QXSTRHASH(T) std::unordered_map<std::string, T >

Note the space after T.

William

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Swig-user mailing list
Swig...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user

Reply all
Reply to author
Forward
0 new messages