Skip to content

Commit

Permalink
Use _WIN32 instead of custom WIN32 macro
Browse files Browse the repository at this point in the history
There are already places where _WIN32 is used n the code so there is no
risk in just replacing the remaining instances of WIN32.

Signed-off-by: Ralph Sennhauser <[email protected]>
  • Loading branch information
seragh committed Aug 24, 2024
1 parent c1fcb80 commit 4776d38
Show file tree
Hide file tree
Showing 26 changed files with 124 additions and 128 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_definitions(-D_DEBUG)
endif()

if(WIN32)
add_definitions(-DWIN32)
endif()

if(BUILD_UNICODE)
add_definitions(-DUNICODE -D_UNICODE)
endif()
Expand Down
4 changes: 2 additions & 2 deletions FCollada/DLLEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "StdAfx.h"

#ifdef FCOLLADA_DLL
#ifdef WIN32
#ifdef _WIN32
HINSTANCE hInstance = nullptr;

BOOL WINAPI DllMain(HINSTANCE _hInstance, ULONG fdwReason, LPVOID UNUSED(lpvReserved))
Expand Down Expand Up @@ -51,6 +51,6 @@ void __attribute((constructor)) DllEntry(void)
void __attribute((destructor)) DllTerminate(void)
{
}
#endif // WIN32
#endif // _WIN32

#endif // FCOLLADA_DLL
4 changes: 2 additions & 2 deletions FCollada/FCollada.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
extern "C"
{
extern
#ifdef WIN32
#ifdef _WIN32
__declspec(dllexport)
//#else
// FCOLLADA_EXPORT
#endif // WIN32
#endif // _WIN32
FUPlugin* CreatePlugin(uint32);
}

Expand Down
4 changes: 2 additions & 2 deletions FCollada/FColladaTest/FMath/FMArrayTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TESTSUITE_TEST(1, Contains)
FailIf(testV.contains(4));

TESTSUITE_TEST(2, Erase)
#ifdef WIN32
#ifdef _WIN32
// GCC reacts badly to compiling this test.
fm::vector<uint32> testV(testValues, testValueCount);
FailIf(!testV.erase((uint32) 3));
Expand All @@ -62,7 +62,7 @@ TESTSUITE_TEST(2, Erase)
EXPS {7} EXPE;
#else
PassIf(true);
#endif // WIN32
#endif // _WIN32

TESTSUITE_TEST(3, Find)
fm::vector<uint32> testV(testValues, testValueCount);
Expand Down
58 changes: 29 additions & 29 deletions FCollada/FColladaTest/FUtils/FUFileManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
#include "FUTestBed.h"
#include "FUtils/FUFileManager.h"
#include "FUtils/FUUri.h"
#if defined(WIN32)
#if defined(_WIN32)
#include <direct.h>
#endif // WIN32
#endif // _WIN32

inline bool PlatformEquivalent(fstring& f, const fchar* check)
{
#ifdef WIN32
#ifdef _WIN32
return IsEquivalent(f, check);
#else
fstring p = check;
p.replace('\\', '/');
return IsEquivalent(f, p);
#endif // WIN32
#endif // _WIN32
}

TESTSUITE_START(FUFileManager)
Expand All @@ -47,23 +47,23 @@ TESTSUITE_TEST(0, Substrings)
static const fchar* checkFilenameReferences[testFilenameCount] = {
FC("C:\\TestFolder\\TestFile.dae"),
FC("/UnixFolder/AbsoluteFile.dae"),
#ifdef WIN32
#ifdef _WIN32
FC("/NetworkFolder/SomeFile.dae"),
#else // WIN32
#else // _WIN32
FC("\\\\WindowsUNCPath/NetworkFolder/SomeFile.dae"),
#endif // WIN32
#endif // _WIN32
FC("file:///strangeURI"),
FC("/UnixFolder/UnixFolder.AnnoyingExtension/SomeFileWithoutExtension"),
FC("file://www.someweb.com/index")
};

#ifdef WIN32
#ifdef _WIN32
static const fchar* checkHostnames[testFilenameCount] =
{ FC(""), FC(""), FC("WindowsUNCPath"), FC(""), FC(""), FC("") };
#else // WIN32
#else // _WIN32
static const fchar* checkHostnames[testFilenameCount] =
{ FC(""), FC(""), FC(""), FC(""), FC(""), FC("") };
#endif // WIN32
#endif // _WIN32

PassIf(IsEquivalent(filename, checkFilenameReferences[i]));
PassIf(IsEquivalent(hostname, checkHostnames[i]));
Expand Down Expand Up @@ -103,7 +103,7 @@ TESTSUITE_TEST(2, RelativePaths)
f = manager.GetCurrentUri().MakeRelative(FC("\\BPath\\BFile"));
PassIf(PlatformEquivalent(f, FC("\\BPath\\BFile")));

#ifdef WIN32
#ifdef _WIN32
// Verify drive-aware relative path generation.
f = manager.GetCurrentUri().MakeRelative(FC("\\AFolder\\AFolder.D\\BFile"));
PassIf(PlatformEquivalent(f, FC(".\\BFile")));
Expand All @@ -119,7 +119,7 @@ TESTSUITE_TEST(2, RelativePaths)
f = manager.GetCurrentUri().MakeRelative(FC("\\\\AFolder\\AFile"));
PassIf(PlatformEquivalent(f, FC("\\\\AFolder\\AFile")));

#ifndef WIN32
#ifndef _WIN32
// Verify the relative file path generation with a Unix file as the root
manager.PopRootFile();
manager.PushRootFile(FC("/ARoot/AFolder/AFolder.D/AFile"));
Expand All @@ -128,7 +128,7 @@ TESTSUITE_TEST(2, RelativePaths)

f = manager.GetCurrentUri().MakeRelative(FC("/ARoot/AFolder/TestOut.pdg"));
PassIf(PlatformEquivalent(f, FC("../TestOut.pdg")));
#endif // WIN32
#endif // _WIN32

// Verify the relative file path generation with a network file as the root
manager.PopRootFile();
Expand All @@ -150,39 +150,39 @@ TESTSUITE_TEST(2, RelativePaths)
PassIf(PlatformEquivalent(f, FC(".\\BPureRelative\\CFile")));

TESTSUITE_TEST(3, AbsolutePaths)
#ifdef WIN32
#ifdef _WIN32
char currentPath[1024];
_getcwd(currentPath, 1023);
currentPath[1023] = 0;
fchar driveLetter = (fchar) toupper(currentPath[0]);
#endif // WIN32
#endif // _WIN32

// Verify the relative file path generation for local files
FUFileManager manager;
manager.PushRootFile(FC("C:\\AFolder\\AFolder.D\\AFile"));
fstring f = manager.GetCurrentUri().MakeAbsolute(FC(".\\BFile"));
#ifdef WIN32
#ifdef _WIN32
PassIf(PlatformEquivalent(f, FC("C:\\AFolder\\AFolder.D\\BFile")));
#else
PassIf(PlatformEquivalent(f, FC("\\C:\\AFolder\\AFolder.D\\BFile")));
#endif // WIN32
#endif // _WIN32

manager.PopRootFile();
manager.PushRootFile(FC("\\AFolder\\AFolder.D\\AFile"));
f = manager.GetCurrentUri().MakeAbsolute(FC("..\\BFile.S"));
#ifdef WIN32
#ifdef _WIN32
fstring check = FC("C:\\AFolder\\BFile.S");
check[0] = driveLetter;
PassIf(PlatformEquivalent(f, check.c_str()));
#else
PassIf(PlatformEquivalent(f, FC("\\AFolder\\BFile.S")));
#endif // WIN32
#endif // _WIN32

TESTSUITE_TEST(4, URI_Generation)
// Verify the URI generation with respect to a local file
FUFileManager manager;

#ifdef WIN32
#ifdef _WIN32
manager.PushRootFile(FC("C:\\AFolder\\AFolder.D\\AFile"));
FUUri uri(FC("C:\\AFolder\\AFolder.D\\BFile"));
fstring f = uri.GetRelativeUri(manager.GetCurrentUri());
Expand All @@ -202,16 +202,16 @@ TESTSUITE_TEST(4, URI_Generation)
PassIf(f == FC("file:///AFolder/AFolder.D/BFile"));
#endif

#ifdef WIN32
#ifdef _WIN32
uri = FUUri(FC("\\\\BNetwork\\BFolder\\BFile"));
f = uri.GetRelativeUri(manager.GetCurrentUri());
PassIf(f == FC("file://BNetwork/BFolder/BFile"));
uri = FUUri(FC("\\\\BNetwork\\BFolder\\BFile"));
f = uri.GetAbsoluteUri();
PassIf(f == FC("file://BNetwork/BFolder/BFile"));
#endif // WIN32
#endif // _WIN32

#ifdef WIN32
#ifdef _WIN32
uri = FUUri(FC("file:///C:/AFolder/BFolder/BFile"));
f = uri.GetRelativeUri(manager.GetCurrentUri());
PassIf(f == FC("../BFolder/BFile"));
Expand All @@ -225,9 +225,9 @@ TESTSUITE_TEST(4, URI_Generation)
uri = FUUri(FC("file:///AFolder/BFolder/BFile"));
f = uri.GetAbsoluteUri();
PassIf(f == FC("file:///AFolder/BFolder/BFile"));
#endif // WIN32
#endif // _WIN32

#ifdef WIN32
#ifdef _WIN32
// Verify the URI generation with respect to a networked file
manager.PushRootFile(FC("\\\\BNetwork\\BFolder\\BSubfolder\\BFile"));
uri = FUUri(FC("C:\\BFolder\\BSubfolder\\CFile"));
Expand All @@ -250,12 +250,12 @@ TESTSUITE_TEST(4, URI_Generation)
uri = FUUri(FC("file://BNetwork/BFolder/BSubfolder/CFile"));
f = uri.GetAbsoluteUri();
PassIf(f == FC("file://BNetwork/BFolder/BSubfolder/CFile"));
#endif // WIN32
#endif // _WIN32

TESTSUITE_TEST(5, BackwardCompatibility)

// Verify the handling of the file paths that we used to export.
#ifdef WIN32
#ifdef _WIN32
FUFileManager manager;
manager.PushRootFile(FC("C:\\AFolder\\AFolder.D\\AFile"));
FUUri uri(FC("file://C|/AFolder/BFolder/BFile"));
Expand All @@ -266,14 +266,14 @@ TESTSUITE_TEST(5, BackwardCompatibility)
PassIf(PlatformEquivalent(f, FC("..\\BFolder\\BFile")));
#else
PassIf(true);
#endif // WIN32
#endif // _WIN32

#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
TESTSUITE_TEST(6, ApplicationFolderName)
fstring applicationFolderName = FUFileManager::GetApplicationFolderName();
FailIf(applicationFolderName.empty()); // really not much else I can test for..

#ifdef WIN32 // at the time of writing, only implemented for WIN32, else returns empty string
#ifdef _WIN32 // at the time of writing, only implemented for WIN32, else returns empty string
fstring moduleFolderName = FUFileManager::GetModuleFolderName();
FailIf(moduleFolderName.empty()); // really not much else I can test for..
#endif
Expand Down
4 changes: 2 additions & 2 deletions FCollada/FColladaTest/FUtils/FUStringTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ TESTSUITE_TEST(2, SubTestSuites)
RUN_TESTSUITE(FUStringBuilder);
RUN_TESTSUITE(FUStringConversion);
RUN_TESTSUITE(FUUniqueStringMap);
#ifndef WIN32
#ifndef _WIN32
PassIf(true);
#endif // WIN32
#endif // _WIN32

TESTSUITE_END
8 changes: 4 additions & 4 deletions FCollada/FMath/FMArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

#include <type_traits>

#ifdef WIN32
#ifdef _WIN32
#pragma warning(disable:4127)
#endif //WIN32
#endif //_WIN32

/** Namespace that contains the overwritten STL classes. */
namespace fm
Expand Down Expand Up @@ -655,7 +655,7 @@ inline bool IsEquivalent(const T* al, size_t acount, const T* bl, size_t bcount)
return equivalent;
}

#ifdef WIN32
#ifdef _WIN32
#pragma warning(default:4127)
#endif //WIN32
#endif //_WIN32
#endif // _FM_ARRAY_H_
2 changes: 1 addition & 1 deletion FCollada/FMath/FMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace FMath
/** Determines if given float is encoding for not a number (NAN).
@param f The float to check.
@return 0 if it is a number, something else if is NAN. */
#ifdef WIN32
#ifdef _WIN32
inline int IsNotANumber(float f) { return _isnan(f); }
#elif __PPU__ || (defined(__APPLE__) && !defined(__GLIBCXX__))
inline int IsNotANumber(float f) { return !isfinite(f); }
Expand Down
8 changes: 4 additions & 4 deletions FCollada/FUtils/FUAssert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <fmt/format.h>

#ifndef WIN32
#ifndef _WIN32
# include <signal.h>
#endif
#include <string>
Expand All @@ -38,7 +38,7 @@ bool FUAssertion::OnAssertionFailed(const char* file, uint32 line)
#ifdef _DEBUG
else
{
# ifdef WIN32
# ifdef _WIN32
int32 buttonPressed = MessageBoxA(nullptr,
message.c_str(),
"Assertion failed.",
Expand All @@ -54,9 +54,9 @@ bool FUAssertion::OnAssertionFailed(const char* file, uint32 line)
{
return true;
}
# else // WIN32
# else // _WIN32
raise(SIGTRAP);
# endif // WIN32
# endif // _WIN32
return false;
}
#else // _DEBUG
Expand Down
2 changes: 1 addition & 1 deletion FCollada/FUtils/FUDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
FUDebug::FUDebug() {}
FUDebug::~FUDebug() {}

#if defined(WIN32)
#if defined(_WIN32)
#define STRING_OUT(sz) OutputDebugString(sz); OutputDebugString(FC("\n"))
#elif defined(__PPU__)
#define STRING_OUT(sz) { fm::string szz = FUStringConversion::ToString(sz); printf(szz.c_str()); printf("\n"); }
Expand Down
4 changes: 2 additions & 2 deletions FCollada/FUtils/FUErrorLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ void FUErrorLog::OnErrorCallback(FUError::Level level, uint32 errorCode, uint32

if (newLine.length() > 0)
{
#ifdef WIN32
#ifdef _WIN32
newLine.append('\r');
#endif // WIN32
#endif // _WIN32
newLine.append('\n');
}
logFile->WriteLine(newLine.ToCharPtr());
Expand Down
6 changes: 3 additions & 3 deletions FCollada/FUtils/FUFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ bool FUFile::Open(const fchar* filename, Mode mode)
}

#ifdef UNICODE
#ifdef WIN32
#ifdef _WIN32
filePtr = _wfopen(filename, openMode);
#else
// No support for Unicode filenames on MacOSX?
// Create copies of filename and openMode, because of memory management.
fm::string string1 = TO_STRING(filename);
fm::string string2 = TO_STRING(openMode);
filePtr = fopen(string1.c_str(), string2.c_str());
#endif // WIN32
#endif // _WIN32
#else
filePtr = fopen(filename, openMode);
#endif // UNICODE
if (filePtr == nullptr)
{
#ifdef WIN32
#ifdef _WIN32
int err;
if (_get_errno(&err) == 0)
{
Expand Down
Loading

0 comments on commit 4776d38

Please sign in to comment.