swprintf confusion - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Open Source Collaboration (https://www.frictionalgames.com/forum/forum-27.html) +--- Forum: HPL1 Engine (https://www.frictionalgames.com/forum/forum-28.html) +--- Thread: swprintf confusion (/thread-3395.html) |
swprintf confusion - RobRendell - 05-17-2010 Hi! Thanks for open-sourcing Penumbra: Overture... I was finding it crashed a lot when I downloaded it from the Humble Indy Bundle, so the opportunity to find and fix the issue(s) is very satisfying... the game looks great, and I'm looking forward to playing it in full I've found an issue that strikes me as odd. My debug build of Overture was failing to find/load any resources. I traced the problem into Impl/System/win32.cpp, where the function Platform::FindFileInDir makes a few calls to swprintf, e.g.: swprintf(sSpec,256,_W("%s\\%s"),asDir.c_str(),asMask.c_str()); However, the version of swprintf my version of Visual Studio 2005 has doesn't take a size parameter... that's snwprintf. VS2005's swprint just takes the output string, format and args, without a size. I've corrected them in my version and the game now loads and runs, but I don't really understand how this could have ever worked. Does swprintf sometimes take an "n" in some library versions or something? RE: swprintf confusion - Urkle - 05-17-2010 swprintf is a PAIN. The Correct (ISO C defintion) version is supposed to have a count parameter, but M$ has an incompatible version that doesn't.. Read this doc about the mess.. Now since we are compiling in C++ mode VS *should* be loading in both versions as overloads and the compiler should compile using the ISO C variant (which is SAFER as you are telling it how big the buffer is.. so no buffer overflows). A way to ensure that C++ version gets loaded is to change the include header to include <cstdio> instead of <stdio.h> and then add a using std; line in the code (or just call std:wprintf() ); http://msdn.microsoft.com/en-us/library/ybk95axf%28VS.71%29.aspx RE: swprintf confusion - Urkle - 05-17-2010 Have you tried the latest EXE that thomas put out there? http://www.frictionalgames.com/forum/thread-3328.html That EXE seems to fix crashes for many other users on Windows. It's actually build from the latest source (ie.. what was released as open source) but with VS 2003. RE: swprintf confusion - RobRendell - 05-17-2010 Thanks for the info on swprintf. I hadn't tried that exe, no. I just downloaded it and gave it a shot, and it did in fact fix my reliable crash problem (entering the office for the first time... no crowbar involved). I'll keep my debug version around, in case any more issues come up Thanks! |