diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 7bb9a2c0a..fb0a263a7 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -425,7 +425,7 @@ example.i(4): Syntax error in input.
467. Overloaded declaration not supported (no type checking rule for 'type')
468. No 'throw' typemap defined for exception type type
469. No or improper directorin typemap defined for type
-470. Possible thread/reentrant unsafe wrapping
+470. Thread/reentrant unsafe wrapping, consider returning by value instead.
471. Unable to use return type type in director method
diff --git a/Lib/java/std_string.i b/Lib/java/std_string.i
index 0c21b2228..334e0ca40 100644
--- a/Lib/java/std_string.i
+++ b/Lib/java/std_string.i
@@ -88,7 +88,7 @@ class string;
$1 = &$1_str;
jenv->ReleaseStringUTFChars($input, $1_pstr); %}
-%typemap(directorout,warning="470:Possible thread/reentrant unsafe wrapping, consider using a plain 'const string' or 'string' return type instead.") const string &
+%typemap(directorout,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const string &
%{if(!$input) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
return $null;
@@ -216,7 +216,7 @@ class wstring;
%typemap(javadirectorin) const wstring & "$jniinput"
%typemap(javadirectorout) const wstring & "$javacall"
-%typemap(directorout,warning="470:Possible thread/reentrant unsafe wrapping, consider using a plain 'const wstring' or 'wstring' return type instead.") const wstring &
+%typemap(directorout,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const wstring &
%{if(!$input) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring");
return $null;
diff --git a/Lib/python/pyptrtypes.swg b/Lib/python/pyptrtypes.swg
index 67dc4e278..1e7ad613c 100644
--- a/Lib/python/pyptrtypes.swg
+++ b/Lib/python/pyptrtypes.swg
@@ -80,7 +80,7 @@
if (res == SWIG_NEWOBJ) delete ptr;
}
- %typemap(directorout,fragment=pyfrag,warning="470:Possible thread/reentrant unsafe wrapping, consider using a plain '"#Type"' return type instead.") const Type& {
+ %typemap(directorout,fragment=pyfrag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const Type& {
Type *ptr = 0;
int res = $input ? asptr_meth($input, &ptr) : 0;
if (!res || !ptr)
diff --git a/Lib/python/pyvaltypes.swg b/Lib/python/pyvaltypes.swg
index 7033e771c..76225eced 100644
--- a/Lib/python/pyvaltypes.swg
+++ b/Lib/python/pyvaltypes.swg
@@ -78,7 +78,7 @@
if (!$input || PyErr_Occurred())
Swig::DirectorTypeMismatchException::raise("Error converting Python object when using as_meth.");
}
- %typemap(directorout,fragment=pyfrag,warning="470:Using thread/reentrant unsafe wrapping, consider using a plain '"#Type"' return type instead.") const Type& {
+ %typemap(directorout,fragment=pyfrag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const Type& {
if ($input) {
static $basetype temp = SWIG_static_cast(SWIG_arg(as_meth($input)),$basetype);
$result = &temp;
diff --git a/Lib/swig.swg b/Lib/swig.swg
index c767977c9..ae866f537 100644
--- a/Lib/swig.swg
+++ b/Lib/swig.swg
@@ -71,6 +71,9 @@
/* Warnings */
#define %warnfilter(...) %feature("warnfilter",`__VA_ARGS__`)
+/* Warnings used in typemaps. Macro names are the same as those in swigwarn.h but prefixed by SWIG_. */
+%define SWIG_WARN_TYPEMAP_THREAD_UNSAFE "470:Thread/reentrant unsafe wrapping, consider returning by value instead." %enddef
+
/* Contract support - Experimental and undocumented */
#define %contract %feature("contract")