1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 13:50:36 +00:00

Move QB64 compiler settings to libqb-common.h

This moves a lot of the preprocessor flags for what compiler/platform
we're using into a libqb-common.h header inside the libqb/include
folder. This gets included at the top of every libqb .cpp file, and is
intended to be fairly small, providing only necessary things like
_WIN32_WINNT (which needs to be defined before including <windows.h> or
friends).
This commit is contained in:
Matthew Kilgore 2022-06-12 00:28:16 -04:00
parent cde7afef30
commit 869e361ee4
7 changed files with 63 additions and 52 deletions

View file

@ -0,0 +1,54 @@
#ifndef INCLUDE_LIBQB_LIBQB_COMMON_H
#define INCLUDE_LIBQB_LIBQB_COMMON_H
// Should be included at the top of every .cpp file
/* Provide some OS/compiler macros.
* QB64_WINDOWS: Is this a Windows system?
* QB64_LINUX: Is this a Linux system?
* QB64_MACOSX: Is this MacOSX, or MacOS or whatever Apple calls it now?
* QB64_UNIX: Is this a Unix-flavoured system?
*
* QB64_BACKSLASH_FILESYSTEM: Does this system use \ for file paths (as opposed to /)?
* QB64_MICROSOFT: Are we compiling with Visual Studio?
* QB64_GCC: Are we compiling with gcc?
* QB64_MINGW: Are we compiling with MinGW, specifically? (Set in addition to QB64_GCC)
*
* QB64_32: A 32bit system (the default)
* QB64_64: A 64bit system (assumes all Macs are 64 bit)
*/
#ifdef WIN32
# define QB64_WINDOWS
// This supports Windows Vista and up
# define _WIN32_WINNT 0x0600
# define QB64_BACKSLASH_FILESYSTEM
# ifdef _MSC_VER
// Do we even support non-mingw compilers on Windows?
# define QB64_MICROSOFT
# else
# define QB64_GCC
# define QB64_MINGW
# endif
#elif defined(__APPLE__)
# define QB64_MACOSX
# define QB64_UNIX
# define QB64_GCC
#elif defined(__linux__)
# define QB64_LINUX
# define QB64_UNIX
# define QB64_GCC
#else
# error "Unknown system; refusing to build. Edit os.h if needed"
#endif
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined(QB64_MACOSX) || defined(__aarch64__)
# define QB64_64
#else
# define QB64_32
#endif
#if !defined(i386) && !defined(__x86_64__)
# define QB64_NOT_X86
#endif
#endif

View file

@ -1,4 +1,6 @@
#include "libqb-common.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View file

@ -1,4 +1,6 @@
#include "libqb-common.h"
#include <stdlib.h>
#include <string.h>
#include <pthread.h>

View file

@ -1,6 +1,5 @@
// FIXME: Move this to some kind of global header
#define _WIN32_WINNT 0x0600
#include "libqb-common.h"
#include <windows.h>
#include <synchapi.h>

View file

@ -1,4 +1,6 @@
#include "libqb-common.h"
#include "mutex.h"
#include "condvar.h"
#include "completion.h"

View file

@ -1,48 +1,5 @@
/* Provide some OS/compiler macros.
* QB64_WINDOWS: Is this a Windows system?
* QB64_LINUX: Is this a Linux system?
* QB64_MACOSX: Is this MacOSX, or MacOS or whatever Apple calls it now?
* QB64_UNIX: Is this a Unix-flavoured system?
*
* QB64_BACKSLASH_FILESYSTEM: Does this system use \ for file paths (as opposed to /)?
* QB64_MICROSOFT: Are we compiling with Visual Studio?
* QB64_GCC: Are we compiling with gcc?
* QB64_MINGW: Are we compiling with MinGW, specifically? (Set in addition to QB64_GCC)
*
* QB64_32: A 32bit system (the default)
* QB64_64: A 64bit system (assumes all Macs are 64 bit)
*/
#ifdef WIN32
# define QB64_WINDOWS
# define QB64_BACKSLASH_FILESYSTEM
# ifdef _MSC_VER
// Do we even support non-mingw compilers on Windows?
# define QB64_MICROSOFT
# else
# define QB64_GCC
# define QB64_MINGW
# endif
#elif defined(__APPLE__)
# define QB64_MACOSX
# define QB64_UNIX
# define QB64_GCC
#elif defined(__linux__)
# define QB64_LINUX
# define QB64_UNIX
# define QB64_GCC
#else
# error "Unknown system; refusing to build. Edit os.h if needed"
#endif
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined(QB64_MACOSX) || defined(__aarch64__)
# define QB64_64
#else
# define QB64_32
#endif
#if !defined(i386) && !defined(__x86_64__)
# define QB64_NOT_X86
#endif
#include "libqb-common.h"
/* common types (not quite an include guard, but allows an including
* file to not have these included.

View file

@ -1,9 +1,4 @@
#define QB64_OS_H_NO_TYPES
#ifdef WIN32
#include "..\..\..\..\os.h"
#else
#include "../../../../os.h"
#endif
#include "../../../../libqb/include/libqb-common.h"
#ifndef CONFIG_H
#define CONFIG_H