I’m trying to use the Metakit library latest update, but I always get an Undefined reference in this piece of code:
bool c4_FileStrategy::DataOpen(const char *fname_, int mode_) {
d4_assert(!_file);
#if q4_WIN32 && !q4_BORC && !q4_WINCE
int flags = _O_BINARY | _O_NOINHERIT | (mode_ > 0 ? _O_RDWR : _O_RDONLY);
int fd = - 1;
if (GetPlatformId() != VER_PLATFORM_WIN32_NT)
fd = _open(fname_, flags);
if (fd == - 1) {
WCHAR wName[MAX_PATH];
MultiByteToWideChar(CP_UTF8, 0, fname_, - 1, wName, MAX_PATH);
fd = _wopen(wName, flags);
}
if (fd != - 1)
_cleanup = _file = _fdopen(fd, mode_ > 0 ? "r+b" : "rb");
#else
_cleanup = _file = fopen(fname_, mode_ > 0 ? "r+b" : "rb");
#if q4_UNIX
if (_file != 0)
fcntl(fileno(_file), F_SETFD, FD_CLOEXEC);
#endif //q4_UNIX
#endif //q4_WIN32 && !q4_BORC && !q4_WINCE
The strange thing (for me) is that, I get this linker error on this line: fcntl(fileno(_file), F_SETFD, FD_CLOEXEC); witch is used only for Linux. The #else part appears in gray, so I thought that code never compiles, so why do I get this undefined reference then ?
Any thoughts ?
PS: with my current older version I have no problem (2.4.6).
edit: I am on Windows and using Tornado (unfornatelly)
edit 2: this is how q4_UNIX is defiend:
#if defined (__MINGW32__)
#define d4_OS_H "win.h"
#elif defined (MSDOS) && defined (__GNUC__)
#define q4_DOS 1
#elif defined(unix) || defined(__unix__) || defined(__GNUC__) || \
defined(_AIX) || defined(__hpux)
#define q4_UNIX 1
#elif defined (__VMS)
#define q4_VMS 1
#elif defined (macintosh)
#define q4_MAC 1
#elif !defined (d4_OS_H)
#define d4_OS_H "win.h"
#endif
You say you are on Windows. This means that this line:
should never have been compiled. This means that the
#ifdef‘s are flawed.You have three options for fixing:
Fix the defines so that this doesn’t get compiled and gets preprocessed out instead.
Comment out the offending lines manually.
Try including
<fcntl.h>, which might fix the issue. That is assuming you even have<fcntl.h>.