From 2d3aa03a5194ee6e9de6c930df46d0fcb3d7fe1c Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 20 May 2016 20:10:39 -0700 Subject: [PATCH] Windows compile fixes --- driver/main.cpp | 36 ++++++++++++++++++++++++++---------- include/amuse/SongState.hpp | 1 + lib/SurroundProfiles.cpp | 1 + 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/driver/main.cpp b/driver/main.cpp index 0a2b230..a77c871 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -9,11 +9,27 @@ #include #include #include +#include #define VOL_FACTOR 0.25 static logvisor::Module Log("amuseplay"); +#if __GNUC__ +__attribute__((__format__ (__printf__, 3, 4))) +#endif +static inline void SNPrintf(boo::SystemChar* str, size_t maxlen, const boo::SystemChar* format, ...) +{ + va_list va; + va_start(va, format); +#if _WIN32 + _vsnwprintf(str, maxlen, format, va); +#else + vsnprintf(str, maxlen, format, va); +#endif + va_end(va); +} + static amuse::IntrusiveAudioGroupData LoadFromArgs(int argc, const boo::SystemChar** argv, std::string& descOut, bool& good) { @@ -68,14 +84,14 @@ static amuse::IntrusiveAudioGroupData LoadFromArgs(int argc, const boo::SystemCh else { /* Now attempt multi-file case */ - char path[1024]; + boo::SystemChar path[1024]; /* Project */ - snprintf(path, 1024, "%s.pro", argv[1]); + SNPrintf(path, 1024, _S("%s.pro"), argv[1]); r.emplace(path, 32 * 1024, false); if (r->hasError()) { - snprintf(path, 1024, "%s.proj", argv[1]); + SNPrintf(path, 1024, _S("%s.proj"), argv[1]); r.emplace(path, 32 * 1024, false); if (r->hasError()) return {nullptr, nullptr, nullptr, nullptr}; @@ -83,11 +99,11 @@ static amuse::IntrusiveAudioGroupData LoadFromArgs(int argc, const boo::SystemCh std::unique_ptr proj = r->readUBytes(r->length()); /* Pool */ - snprintf(path, 1024, "%s.poo", argv[1]); + SNPrintf(path, 1024, _S("%s.poo"), argv[1]); r.emplace(path, 32 * 1024, false); if (r->hasError()) { - snprintf(path, 1024, "%s.pool", argv[1]); + SNPrintf(path, 1024, _S("%s.pool"), argv[1]); r.emplace(path, 32 * 1024, false); if (r->hasError()) return {nullptr, nullptr, nullptr, nullptr}; @@ -95,11 +111,11 @@ static amuse::IntrusiveAudioGroupData LoadFromArgs(int argc, const boo::SystemCh std::unique_ptr pool = r->readUBytes(r->length()); /* Sdir */ - snprintf(path, 1024, "%s.sdi", argv[1]); + SNPrintf(path, 1024, _S("%s.sdi"), argv[1]); r.emplace(path, 32 * 1024, false); if (r->hasError()) { - snprintf(path, 1024, "%s.sdir", argv[1]); + SNPrintf(path, 1024, _S("%s.sdir"), argv[1]); r.emplace(path, 32 * 1024, false); if (r->hasError()) return {nullptr, nullptr, nullptr, nullptr}; @@ -107,11 +123,11 @@ static amuse::IntrusiveAudioGroupData LoadFromArgs(int argc, const boo::SystemCh std::unique_ptr sdir = r->readUBytes(r->length()); /* Samp */ - snprintf(path, 1024, "%s.sam", argv[1]); + SNPrintf(path, 1024, _S("%s.sam"), argv[1]); r.emplace(path, 32 * 1024, false); if (r->hasError()) { - snprintf(path, 1024, "%s.samp", argv[1]); + SNPrintf(path, 1024, _S("%s.samp"), argv[1]); r.emplace(path, 32 * 1024, false); if (r->hasError()) return {nullptr, nullptr, nullptr, nullptr}; @@ -635,7 +651,7 @@ struct AppCallback : boo::IApplicationCallback int appMain(boo::IApplication* app) { /* Event window */ - m_win = app->newWindow("amuseplay", 1); + m_win = app->newWindow(_S("amuseplay"), 1); m_win->setCallback(&m_events); m_win->setWindowFrame(100, 100, 100, 100); m_win->setStyle(~boo::EWindowStyle::Resize); diff --git a/include/amuse/SongState.hpp b/include/amuse/SongState.hpp index 85bb4ca..f0c3294 100644 --- a/include/amuse/SongState.hpp +++ b/include/amuse/SongState.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "optional.hpp" #include "Entity.hpp" diff --git a/lib/SurroundProfiles.cpp b/lib/SurroundProfiles.cpp index f2269d0..0c6218b 100644 --- a/lib/SurroundProfiles.cpp +++ b/lib/SurroundProfiles.cpp @@ -1,5 +1,6 @@ #include "amuse/SurroundProfiles.hpp" #include +#include #include namespace amuse