From 213774e0b63810b318bbaaa577e10a3de02263d5 Mon Sep 17 00:00:00 2001 From: Marvin Greenberg Date: Mon, 3 Feb 2014 11:34:55 -0500 Subject: [PATCH] Fix issue on clang about implicit instantiation of undefined template Generated code does not include , which is referenced in templates. Clang may be incorrectly or aggresively instantiating some template. E.g., import_stl_b_wrap.cxx:3199:51: error: implicit instantiation of undefined template 'std::__1::basic_string --- Lib/std/std_common.i | 8 +++++++- Lib/typemaps/traits.swg | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Lib/std/std_common.i b/Lib/std/std_common.i index 7c52880e9..cb91bc632 100644 --- a/Lib/std/std_common.i +++ b/Lib/std/std_common.i @@ -73,7 +73,13 @@ namespace std { #endif %} -%fragment("StdTraitsCommon","header") %{ +%fragment("StdStringInclude","header") %{ +#ifdef __clang__ +#include +#endif +%} + +%fragment("StdTraitsCommon","header",fragment="StdStringInclude") %{ namespace swig { template struct noconst_traits { diff --git a/Lib/typemaps/traits.swg b/Lib/typemaps/traits.swg index b39eb3946..584d480c2 100644 --- a/Lib/typemaps/traits.swg +++ b/Lib/typemaps/traits.swg @@ -26,7 +26,13 @@ #include %} -%fragment("Traits","header") +%fragment("StdStringInclude","header") %{ +#ifdef __clang__ +#include +#endif +%} + +%fragment("Traits","header",fragment="StdStringInclude") { namespace swig { /*