BSD detection

5 messages BitcoinTalk dkaparis, Satoshi Nakamoto August 11, 2010 — August 13, 2010
dkaparis August 11, 2010 14:00 UTC Source ·

There is this piece of code in headers.h:

#ifdef WXMAC_OSX #define WXMAC 1 #define WXOSX 1 #define BSD 1 #endif #endif

In my testing it’s not caught on FreeBSD 8.1

I propose it be changed to:

#if (defined(unix) || defined(unix)) && !defined(USG) #include <sys/param.h> #endif

And then checks for BSD should be #ifdef BSD This is the recommended way of detecting BSD in the FreeBSD Porter’s Handbook (http://www.freebsd.org/doc/en/books/porters-handbook/porting-versions.html).

This change is already done in my CMake tree.

Satoshi Nakamoto August 12, 2010 00:02 UTC Source ·
Quote from: dkaparis on August 11, 2010, 2:00:16 PM UTC

There is this piece of code in headers.h:

#ifdef __WXMAC_OSX__
#define __WXMAC__ 1
#define __WXOSX__ 1
#define __BSD__ 1
#endif
#endif

That code was a bad idea anyway, I’m deleting it.  Any Mac code should only use WXMAC_OSX, not WXMAC or WXOSX, and we should stop using BSD.

#if (defined(__unix__) || defined(unix)) && !defined(USG)
#include <sys/param.h>
#endif

Will that definitely cause BSD to be defined on Mac?

dkaparis August 12, 2010 08:24 UTC Source ·
Quote from: satoshi on August 11, 2010, 3:02:06 PM UTC

Quote #if (defined(unix) || defined(unix)) && !defined(USG) #include #endif

Will that definitely cause BSD to be defined on Mac?

Don’t know if Mac OS X is technically a BSD and I don’t have access to a Mac, maybe someone else may test it. If there are other Mac (and not BSD) specialties, then we’d need to check both for WXMAC_OSX and BSD or detect these in some other way altogether.

Satoshi Nakamoto August 12, 2010 21:14 UTC Source ·

This is in SVN rev 130.  Check that it compiles right.

#if (defined(__unix__) || defined(unix)) && !defined(USG)
#include <sys/param.h>  // to get BSD define
#endif
#ifdef __WXMAC_OSX__
#ifndef BSD
#define BSD 1
#endif
#endif
dkaparis August 13, 2010 15:38 UTC Source ·

Incorporated into the CMake tree. No problems on Windows and FreeBSD.