Skip to content

Commit

Permalink
Drop use of LINUX define
Browse files Browse the repository at this point in the history
Instead of defining LINUX on many platforms just use the standard
platform macros. As there is no "config.h" (yet) this also prevents
consumers from having to define it.

Signed-off-by: Ralph Sennhauser <[email protected]>
  • Loading branch information
seragh committed Aug 18, 2024
1 parent 495638e commit 669c614
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 70 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ endif()

if(WIN32)
add_definitions(-DWIN32)
elseif(NOT APPLE)
add_definitions(-DLINUX)
endif()

if(BUILD_UNICODE)
Expand Down
2 changes: 1 addition & 1 deletion FCollada/DLLEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ BOOL WINAPI DllMain(HINSTANCE _hInstance, ULONG fdwReason, LPVOID UNUSED(lpvRese
hInstance = _hInstance;
return TRUE;
}
#elif defined(__APPLE__) || defined(LINUX)
#else
void __attribute((constructor)) DllEntry(void)
{
}
Expand Down
6 changes: 1 addition & 5 deletions FCollada/FCDocument/FCDEffectStandard.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ class FCDEffect;
class FCDTexture;
class FCDEffectParameter;

#if defined(WIN32)
template <class T, int Q> class FCOLLADA_EXPORT FCDEffectParameterAnimatableT; /**< Trick Doxygen. */
#elif defined(LINUX) || defined(__APPLE__)
template <class T, int Q> class FCDEffectParameterAnimatableT; /**< Trick Doxygen. */
#endif // LINUX
template <class T, int Q> class FCOLLADA_EXPORT FCDEffectParameterAnimatableT;
typedef FCDEffectParameterAnimatableT<FMVector4, 1> FCDEffectParameterColor4; /**< A RGBA color effect parameter. */
typedef FCDEffectParameterAnimatableT<float, 0> FCDEffectParameterFloat; /**< A floating-point value effect parameter. */

Expand Down
6 changes: 1 addition & 5 deletions FCollada/FCDocument/FCDEffectTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ class FCDEffectStandard;
class FCDEffectTechnique;
class FCDGeometryInstance;

#if defined(WIN32)
template <class T, int Q> class FCOLLADA_EXPORT FCDEffectParameterAnimatableT; /**< Trick Doxygen. */
#elif defined(LINUX) || defined(__APPLE__)
template <class T, int Q> class FCDEffectParameterAnimatableT; /**< Trick Doxygen. */
#endif // LINUX
template <class T, int Q> class FCOLLADA_EXPORT FCDEffectParameterAnimatableT;
typedef FCDEffectParameterAnimatableT<FMVector4, 1> FCDEffectParameterColor4; /**< A RGBA color effect parameter. */
typedef FCDEffectParameterAnimatableT<float, 0> FCDEffectParameterFloat; /**< A floating-point value effect parameter. */

Expand Down
6 changes: 1 addition & 5 deletions FCollada/FCDocument/FCDTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ class FCDEffectParameterSampler;
class FCDEffectStandard;
class FCDImage;

#if defined(WIN32)
template <class T> class FCOLLADA_EXPORT FCDEffectParameterT; /**< Trick Doxygen. */
#elif defined(LINUX) || defined(__APPLE__)
template <class T> class FCDEffectParameterT; /**< Trick Doxygen. */
#endif // LINUX
template <class T> class FCOLLADA_EXPORT FCDEffectParameterT;
typedef FCDEffectParameterT<int32> FCDEffectParameterInt; /**< An integer effect parameter. */

/**
Expand Down
9 changes: 2 additions & 7 deletions FCollada/FCDocument/FCDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@
#include "FUtils/FUParameter.h"
#endif // _FU_PARAMETER_H_

#if defined(WIN32)
template <class T> class FCOLLADA_EXPORT FCDLibrary; /**< Trick Doxygen. */
template <class T> class FCOLLADA_EXPORT FUUniqueStringMapT; /**< Trick Doxygen. */
#elif defined(LINUX) || defined(__APPLE__)
template <class T> class FCDLibrary; /**< Trick Doxygen. */
template <class T> class FUUniqueStringMapT; /**< Trick Doxygen. */
#endif // LINUX
template <class T> class FCOLLADA_EXPORT FCDLibrary;
template <class T> class FCOLLADA_EXPORT FUUniqueStringMapT;

class FCDAnimated;
class FCDAnimation;
Expand Down
2 changes: 0 additions & 2 deletions FCollada/FMath/FMFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
#ifndef _FM_FLOAT_H_
#define _FM_FLOAT_H_

#if !defined(_INC_FLOAT) && (defined (WIN32) || defined (LINUX) || defined(__APPLE__))
#include <float.h>
#endif // _INC_FLOAT, WIN32 and LINUX

/** The default tolerance for double-sized floating-point comparison functions. */
#define DBL_TOLERANCE 0.0001
Expand Down
10 changes: 5 additions & 5 deletions FCollada/FUtils/FUDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
FUDebug::FUDebug() {}
FUDebug::~FUDebug() {}

#if defined(LINUX) || defined(__APPLE__)
#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"); }
#else
#if defined(UNICODE)
#define STRING_OUT(sz) fmt::print(stderr, "{}", TO_STRING(sz).c_str()); std::fflush(stderr);
#else
#define STRING_OUT(sz) fmt::print(stderr, "{}", sz); std::fflush(stderr);
#endif // UNICODE
#elif 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"); }
#endif

#ifdef _DEBUG
Expand Down
24 changes: 12 additions & 12 deletions FCollada/FUtils/FUFileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#elif defined(__APPLE__)
#include <mach-o/dyld.h>
#include <sys/stat.h>
#elif defined(LINUX)
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Expand Down Expand Up @@ -216,7 +216,7 @@ bool FUFileManager::MakeDirectory(const fstring& directory)
if (_mkdir(TO_STRING(absoluteDirectory).c_str()) == 0) return true;
errno_t err; _get_errno(&err);
if (err == EEXIST) return true;
#elif defined(LINUX) || defined(__APPLE__)
#else
if (mkdir(TO_STRING(absoluteDirectory).c_str(), std::numeric_limits<mode_t>::max()) == 0)
return true; // I think this means all permissions..
#endif // WIN32
Expand Down Expand Up @@ -378,7 +378,16 @@ fstring FUFileManager::GetApplicationFolderName()
GetModuleFileName(NULL, buffer, 1024);
buffer[1023] = 0;
_uri = buffer;
#elif defined(LINUX)
#elif defined(__APPLE__)
char path[1024];
uint32_t pathLength = 1023;
if(_NSGetExecutablePath(path, &pathLength))
{
// doesn't fit
path[0] = '\0';
}
_uri = TO_FSTRING((const char*) path);
#else
char path[1024];
char path2[1024];
struct stat stat_buf;
Expand All @@ -403,15 +412,6 @@ fstring FUFileManager::GetApplicationFolderName()
//"path" should have the application folder path in it.
const char * exeName = &path[0];
_uri = TO_FSTRING(exeName);
#elif defined(__APPLE__)
char path[1024];
uint32_t pathLength = 1023;
if(_NSGetExecutablePath(path, &pathLength))
{
// doesn't fit
path[0] = '\0';
}
_uri = TO_FSTRING((const char*) path);
#endif // WIN32

fstring out;
Expand Down
6 changes: 3 additions & 3 deletions FCollada/FUtils/FUPluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define ffindclose _findclose
#define ffindnext _findnext
#endif
#elif defined(__APPLE__) || defined(LINUX)
#else
#include <dlfcn.h>
#include <dirent.h>
#endif //WIN32
Expand Down Expand Up @@ -125,7 +125,7 @@ void FUPluginManager::LoadPluginsInFolderName(const fstring& folderName, const f
ffindclose(folderHandle);
}

#elif defined(__APPLE__) || defined(LINUX)
#else
fm::string s_filter = TO_STRING(filter);
if (s_filter.length() > 0 && s_filter.front() == '*') s_filter.erase(0, 1);
if (s_filter.length() > 0 && s_filter.back() == '*') s_filter.pop_back();
Expand Down Expand Up @@ -176,7 +176,7 @@ FUPluginManager::~FUPluginManager()
{
#if defined(WIN32)
if ((*it)->module != NULL) FreeLibrary((*it)->module);
#elif defined(LINUX) || defined(__APPLE__)
#else
if ((*it)->module != NULL) dlclose((*it)->module);
#endif // WIN32
}
Expand Down
2 changes: 1 addition & 1 deletion FCollada/FUtils/FUPluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FCOLLADA_EXPORT FUPluginManager
fstring filename;
#if defined(WIN32)
HMODULE module;
#elif defined(__APPLE__) || defined(LINUX)
#else
void* module;
#endif // WIN32

Expand Down
28 changes: 12 additions & 16 deletions FCollada/FUtils/Platforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@
#include <windows.h>
#include <stdio.h>
#include <wchar.h>
#else
#ifdef __APPLE__

#elif __APPLE__

#include <ctype.h>
#include <wctype.h>
#include <unistd.h>
#include <string.h>
#include <wchar.h>
#include <stdint.h>
#else // __APPLE__
#if defined(LINUX) || defined(__PPU__)

#else

#include <ctype.h>
#include <wctype.h>
#include <unistd.h>
Expand All @@ -69,12 +71,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#else // OTHER...
#error "Unsupported platform."
#endif // LINUX || __PPU__
#endif // __APPLE__

#endif // WIN32
#endif // WIN32 __APPLE__

// Cross-platform type definitions
#ifdef WIN32
Expand All @@ -88,7 +86,7 @@ typedef unsigned short uint16;
typedef unsigned long uint32;
typedef unsigned __int64 uint64;

#else // For LINUX and __APPLE__
#else

typedef int8_t int8;
typedef int16_t int16;
Expand All @@ -107,17 +105,15 @@ typedef uint8_t byte;
#endif // PLATFORMS

// Important functions that some OSes have missing!
#if defined(__APPLE__) || defined (LINUX)
#if defined(__PPU__)
#define glClearDepth glClearDepthf
#elif !defined(WIN32)
inline char* strlower(char* str) { char* it = str; while (*it != 0) { *it = tolower(*it); ++it; } return str; }
inline wchar_t* wcslwr(wchar_t* str) { wchar_t* it = str; while (*it != 0) { *it = towlower(*it); ++it; } return str; }
inline int wcsicmp(const wchar_t* s1, const wchar_t* s2) { wchar_t c1 = *s1, c2 = *s2; while (c1 != 0 && c2 != 0) { if (c1 >= 'a' && c1 <= 'z') c1 -= 'a' + 'A'; if (c2 >= 'a' && c2 <= 'z') c2 -= 'a' + 'A'; if (c2 < c1) return -1; else if (c2 > c1) return 1; c1 = *(++s1); c2 = *(++s2); } return 0; }
#define _stricmp strcasecmp
#define _getcwd getcwd

#elif defined(__PPU__)
#define glClearDepth glClearDepthf

#endif // __APPLE__ and LINUX
#endif

// Cross-platform needed functions
#ifdef WIN32
Expand Down
4 changes: 2 additions & 2 deletions FColladaTools/FCExport/FCExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ int main(int argc, const char* argv[], char* envp[])
{
#ifdef WIN32
_environ = envp;
#else //LINUX
#else
environ = envp;
#endif //WIN32 and LINUX
#endif // WIN32
if (argc != 3)
{
std::cout << "Expecting two arguments:" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions FColladaTools/FCProcessImages/FCProcessImages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ int main(int argc, const char* argv[], char* envp[])
{
#ifdef WIN32
_environ = envp;
#else //LINUX
#else
environ = envp;
#endif //WIN32 and LINUX
#endif //WIN32
if (argc != 3)
{
std::cout << "Expecting two arguments:" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions FColladaTools/FCProcessMeshes/FCProcessMeshes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ int main(int argc, const char* argv[], char* envp[])
{
#ifdef WIN32
_environ = envp;
#else //LINUX
#else
environ = envp;
#endif //WIN32 and LINUX
#endif // WIN32

// variables for processing
ProcessMeshesOptions options;
Expand Down

0 comments on commit 669c614

Please sign in to comment.