Lua example warning removal fixes for vc++

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10539 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2008-06-21 15:21:29 +00:00
commit 7a68c5c003
4 changed files with 26 additions and 7 deletions

View file

@ -16,7 +16,7 @@ void sort_int(int* arr, int len)
// ditto doubles // ditto doubles
int compare_double(const void * a, const void * b) int compare_double(const void * a, const void * b)
{ {
return ( *(double*)a - *(double*)b ); return (int)( *(double*)a - *(double*)b );
} }
void sort_double(double* arr, int len) void sort_double(double* arr, int len)

View file

@ -11,6 +11,17 @@ We will be using the luaL_dostring()/lua_dostring() function to call into lua
*/ */
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
# define _SCL_SECURE_NO_DEPRECATE
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -108,7 +119,7 @@ int call_va (lua_State *L,const char *func, const char *sig, ...) {
endwhile: endwhile:
/* do the call */ /* do the call */
nres = strlen(sig); /* number of expected results */ nres = (int)strlen(sig); /* number of expected results */
if (lua_pcall(L, narg, nres, 0) != 0) /* do the call */ if (lua_pcall(L, narg, nres, 0) != 0) /* do the call */
{ {
printf("error running function `%s': %s\n",func, lua_tostring(L, -1)); printf("error running function `%s': %s\n",func, lua_tostring(L, -1));

View file

@ -5,6 +5,17 @@ passing C++ objects to this function.
*/ */
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
# define _SCL_SECURE_NO_DEPRECATE
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -70,9 +81,6 @@ int call_onEvent(lua_State *L, Event e) {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
int ok;
int res;
char str[80];
printf("[C++] Welcome to the simple embedded Lua example v3\n"); printf("[C++] Welcome to the simple embedded Lua example v3\n");
printf("[C++] We are in C++\n"); printf("[C++] We are in C++\n");
printf("[C++] opening a Lua state & loading the libraries\n"); printf("[C++] opening a Lua state & loading the libraries\n");

View file

@ -54,14 +54,14 @@ void ShapeOwner::add(Shape* ptr) // this method takes ownership of the object
Shape* ShapeOwner::get(int idx) // this pointer is still owned by the class (assessor) Shape* ShapeOwner::get(int idx) // this pointer is still owned by the class (assessor)
{ {
if (idx<0 || idx>=shapes.size()) if (idx < 0 || idx >= static_cast<int>(shapes.size()))
return NULL; return NULL;
return shapes[idx]; return shapes[idx];
} }
Shape* ShapeOwner::remove(int idx) // this method returns memory which must be deleted Shape* ShapeOwner::remove(int idx) // this method returns memory which must be deleted
{ {
if (idx<0 || idx>=shapes.size()) if (idx < 0 || idx >= static_cast<int>(shapes.size()))
return NULL; return NULL;
Shape* ptr=shapes[idx]; Shape* ptr=shapes[idx];
shapes.erase(shapes.begin()+idx); shapes.erase(shapes.begin()+idx);