Skip to content

Commit

Permalink
Resolved multiple warnings on Apple targets. (#1145)
Browse files Browse the repository at this point in the history
* Update CFFI.cpp

* Update Dynamic.cpp

* Update mac-toolchain.xml

* Update mac-toolchain.xml

* Update my_api.cpp

* Update Immix.cpp

* Removed whitespaces and adjusted ios and tvos toolchains.
  • Loading branch information
MAJigsaw77 authored Aug 30, 2024
1 parent 17ac6e8 commit 08f88ff
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class PointerData : public hx::Object
String toString()
{
char buf[100];
sprintf(buf,"Pointer(%p)", mValue);
snprintf(buf,sizeof(buf),"Pointer(%p)", mValue);
return String(buf);
}
String __ToString() const { return String(mValue); }
Expand Down
2 changes: 1 addition & 1 deletion src/hx/CFFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Abstract_obj : public Object
return _hxcpp_toString( Dynamic(this) );

char buffer[40];
sprintf(buffer,"0x%p", mHandle);
snprintf(buffer,sizeof(buffer),"0x%p", mHandle);

return HX_CSTRING("Abstract(") +
__hxcpp_get_kind(this) +
Expand Down
6 changes: 3 additions & 3 deletions src/hx/gc/Immix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4632,11 +4632,11 @@ class GlobalAllocator

char strBuf[100];
if (bytes<k)
sprintf(strBuf,"%d", (int)bytes);
snprintf(strBuf,sizeof(strBuf),"%d", (int)bytes);
else if (bytes<meg)
sprintf(strBuf,"%.2fk", (double)bytes/k);
snprintf(strBuf,sizeof(strBuf),"%.2fk", (double)bytes/k);
else
sprintf(strBuf,"%.2fmb", (double)bytes/meg);
snprintf(strBuf,sizeof(strBuf),"%.2fmb", (double)bytes/meg);
return strBuf;
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/hx/libs/mysql/my_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ static void error( MYSQL *m, const char *err, const char *param ) {
p2[max - 2] = '.';
p2[max - 1] = '.';
p2[max] = 0;
sprintf(m->last_error,err,param);
snprintf(m->last_error,sizeof(m->last_error),err,param);
free(p2);
return;
}
}
sprintf(m->last_error,err,param);
snprintf(m->last_error,sizeof(m->last_error),err,param);
m->errcode = -1;
}

Expand Down Expand Up @@ -408,7 +408,7 @@ const char *mysql_character_set_name( MYSQL *m ) {
const char *name = myp_charset_name(m->infos.server_charset);
if( name == NULL ) {
static char tmp[512];
sprintf(tmp,"#%d",m->infos.server_charset);
snprintf(tmp,sizeof(tmp),"#%d",m->infos.server_charset);
return tmp;
}
return name;
Expand Down
12 changes: 8 additions & 4 deletions toolchain/appletvos-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
<!-- <cppflag value="-fvisibility-inlines-hidden"/> -->
<pchflag value="-x" />
<pchflag value="c++-header" />
<flag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<flag value="-stdlib=libc++" if="HXCPP_CPP11" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<flag value="-g" if="HXCPP_DEBUG_LINK"/>
<flag value="-O2" unless="debug"/>
<flag value="-arch"/>
Expand Down Expand Up @@ -69,8 +71,10 @@
<linker id="dll" exe="g++" >
<exe name="xcrun --sdk appletvos${TVOS_VER} g++" if="HXCPP_GCC" />
<exe name="xcrun --sdk appletvos${TVOS_VER} clang++" />
<flag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<flag value="-stdlib=libc++" if="HXCPP_CPP11" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<flag value="-dynamiclib"/>
<flag value="-arch"/>
<flag value="arm64" if="HXCPP_ARM64" />
Expand Down
12 changes: 8 additions & 4 deletions toolchain/appletvsim-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
<!-- <cppflag value="-fvisibility-inlines-hidden"/> -->
<pchflag value="-x" />
<pchflag value="c++-header" />
<flag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<flag value="-stdlib=libc++" if="HXCPP_CPP11" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<flag value="-g" if="HXCPP_DEBUG_LINK"/>
<flag value="-O2" unless="debug"/>
<flag value="-fmessage-length=0"/>
Expand Down Expand Up @@ -76,8 +78,10 @@
<linker id="dll" exe="g++" >
<exe name="xcrun --sdk appletvsimulator${TVOS_VER} g++" if="HXCPP_GCC" />
<exe name="xcrun --sdk appletvsimulator${TVOS_VER} clang++" />
<flag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<flag value="-stdlib=libc++" if="HXCPP_CPP11" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11" />
<flag value="-dynamiclib"/>
<flag value="-arch"/>
<flag value="i386" unless="HXCPP_M64"/>
Expand Down
6 changes: 4 additions & 2 deletions toolchain/iphoneos-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@
<exe name="xcrun --sdk iphoneos${IPHONE_VER} g++" if="HXCPP_GCC" />
<exe name="xcrun --sdk iphoneos${IPHONE_VER} clang++" />
<flag value="-Wl,-cache_path_lto,/tmp" if="HXCPP_OPTIMIZE_LINK_INCREMENTAL" unless="debug"/>
<flag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<flag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<flag value="-dynamiclib"/>
<flag value="-arch"/>
<flag value="armv6" if="HXCPP_ARMV6" />
Expand Down
6 changes: 4 additions & 2 deletions toolchain/iphonesim-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@
<linker id="dll" exe="g++" >
<exe name="xcrun --sdk iphonesimulator${IPHONE_VER} g++" if="HXCPP_GCC" />
<exe name="xcrun --sdk iphonesimulator${IPHONE_VER} clang++" />
<flag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<flag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<cppflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<cppflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<mmflag value="-stdlib=libstdc++" if="FORCE_LIBGCC" />
<mmflag value="-stdlib=libc++" if="HXCPP_CPP11 || HXCPP_CPP17" />
<flag value="-dynamiclib"/>
<flag value="-arch"/>
<flag value="i386" unless="HXCPP_M64"/>
Expand Down
18 changes: 13 additions & 5 deletions toolchain/mac-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
<cppflag value="-Wc++14-extensions" if="HXCPP_CPP14"/>
<cppflag value="-std=c++17" if="HXCPP_CPP17"/>
<cppflag value="-Wc++17-extensions" if="HXCPP_CPP17"/>
<flag value="-stdlib=libc++" unless="STDLIBCPP" />
<flag value="-stdlib=libstdc++" if="STDLIBCPP" />
<cppflag value="-stdlib=libc++" unless="STDLIBCPP" />
<cppflag value="-stdlib=libstdc++" if="STDLIBCPP" />
<mmflag value="-stdlib=libc++" unless="STDLIBCPP" />
<mmflag value="-stdlib=libstdc++" if="STDLIBCPP" />

<cppflag value="-frtti"/>
<pchflag value="-x" />
<pchflag value="c++-header" />
Expand Down Expand Up @@ -74,8 +77,10 @@
<fromfile value="" if="GCC_OLD" />
<flag value="-Wl,-bundle,-bundle_loader,${dll_import_link}" if="dll_import_link" />
<flag value="-Wl,-cache_path_lto,/tmp" if="HXCPP_LTO_THIN" unless="debug"/>
<flag value="-stdlib=libc++" unless="STDLIBCPP" />
<flag value="-stdlib=libstdc++" if="STDLIBCPP" />
<cppflag value="-stdlib=libc++" unless="STDLIBCPP" />
<cppflag value="-stdlib=libstdc++" if="STDLIBCPP" />
<mmflag value="-stdlib=libc++" unless="STDLIBCPP" />
<mmflag value="-stdlib=libstdc++" if="STDLIBCPP" />
<flag value="-fpic"/>
<flag value="-fPIC"/>
<flag value="-dynamiclib"/>
Expand All @@ -99,7 +104,10 @@
<flag value="-Wl,-rpath,${HXCPP_RPATH}" if="HXCPP_RPATH" />
<flag value="-Wl,-cache_path_lto,/tmp" if="HXCPP_OPTIMIZE_LINK_INCREMENTAL" unless="debug"/>
<fromfile value="" if="GCC_OLD" />
<flag value="-stdlib=libstdc++" if="STDLIBCPP" />
<cppflag value="-stdlib=libc++" unless="STDLIBCPP" />
<cppflag value="-stdlib=libstdc++" if="STDLIBCPP" />
<mmflag value="-stdlib=libc++" unless="STDLIBCPP" />
<mmflag value="-stdlib=libstdc++" if="STDLIBCPP" />
<flag value="-framework"/>
<flag value="Cocoa"/>
<flag value="-isysroot" unless="LEGACY_MACOSX_SDK"/>
Expand Down

0 comments on commit 08f88ff

Please sign in to comment.