So I have the following C++
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
int hello(char *str);
int hello(char *str) {
cout << "Hello World: " << str << endl;
return 0;
}
And the following swig interface
%module sphp
%{
extern int hello(char *str);
%}
extern int hello(char *str);
And I can compile and use this in php,
php> hello("testing!");
This all is wicked!
Only problem is
php> hello(3);
is still valid. I don't want this, it seems swig silently casts types
/*@SWIG:/usr/share/swig2.0/php/utils.i,62,CONVERT_STRING_IN@*/
if ((*args[0])->type==IS_NULL) {
arg1 = (char *) 0;
} else {
convert_to_string_ex(args[0]);
arg1 = (char *) Z_STRVAL_PP(args[0]);
}
/*@SWIG@*/;
Now I don't want to be editing the wrapper, because its auto generated. Is there a way I can turn off this silent conversion, so that hello(3) will throw exceptions or errors, or can I give hello a hint about the type of the php argument it was originally passed?