Files
pip/libs/main/piplatform.h
andrey 8828aa3f81 fix: build PIP on Pico and arbitrary flag combinations
- guard console subsystem (PIScreen/PIScreenTile/tiles/PITerminal/
  PIKbdListener) by PIP_HAS_THREADS plus a TTY or Windows console
  (new PIP_HAS_TTY platform macro) - termios is not available on
  bare-metal newlib
- guard cloud subsystem (PICloudBase/Client/Server/TCP) by
  PIP_HAS_SOCKET and PIP_HAS_THREADS
- add PIP_BUILD_CONSOLE/PIP_BUILD_CLOUD to the auto-disable flag
  dependencies in CMake
- PIP_CAN (SocketCAN) is Linux-only, exclude other platforms
- on Pico keep sockets/MQTT off by default: pico-sdk lwip provides
  only a partial POSIX socket layer (no netinet/in.h, poll.h)
- PITranslator: inline no-op definitions when PIP_HAS_FILESYSTEM is
  off so the _tr literal links
- PIIODevice: guard read_func/write_func EVENT_HANDLERs (no-threads)
- piwaitevent_p.cpp: drop unused sys/ioctl.h include (missing on
  arm-none-eabi, broke Pico builds)
2026-08-22 15:49:05 +03:00

214 lines
6.0 KiB
C

/*! \file piplatform.h
* \ingroup Core
* \~\brief
* \~english Public platform and compiler detection macros
* \~russian Публичные макросы определения платформы и компилятора
*
* \~\details
* \~english
* This header defines portability macros that can be used in public PIP-aware
* code for platform, compiler and architecture checks.
* \~russian
* Этот заголовок определяет макросы переносимости, которые можно использовать
* в публичном PIP-коде для проверки платформы, компилятора и архитектуры.
*/
/*
PIP - Platform Independent Primitives
Platform and compiler macros
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPLATFORM_H
#define PIPLATFORM_H
#include <pip_export.h>
#ifdef DOXYGEN
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for Windows targets.
//! \~russian Определяется для целевых сборок Windows.
# define WINDOWS
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for Linux targets.
//! \~russian Определяется для целевых сборок Linux.
# define LINUX
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for macOS targets.
//! \~russian Определяется для целевых сборок macOS.
# define MAC_OS
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for Android targets.
//! \~russian Определяется для целевых сборок Android.
# define ANDROID
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for QNX targets.
//! \~russian Определяется для целевых сборок QNX.
# define QNX
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for FreeBSD targets.
//! \~russian Определяется для целевых сборок FreeBSD.
# define FREE_BSD
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for reduced embedded PIP builds.
//! \~russian Определяется для облегченных встраиваемых сборок PIP.
# define PIP_EMBEDDED
//! \~\ingroup Core
//! \~\brief
//! \~english Defined when the target architecture is 32-bit.
//! \~russian Определяется, когда целевая архитектура 32-битная.
# define ARCH_BITS_32
//! \~\ingroup Core
//! \~\brief
//! \~english Defined when the target architecture is 64-bit.
//! \~russian Определяется, когда целевая архитектура 64-битная.
# define ARCH_BITS_64
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for GCC-compatible compilers.
//! \~russian Определяется для GCC-совместимых компиляторов.
# define CC_GCC
//! \~\ingroup Core
//! \~\brief
//! \~english Encoded GCC major and minor version for \a CC_GCC builds.
//! \~russian Содержит закодированную основную и дополнительную версию GCC для сборок с \a CC_GCC.
# define CC_GCC_VERSION
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for Microsoft Visual C++.
//! \~russian Определяется для Microsoft Visual C++.
# define CC_VC
//! \~\ingroup Core
//! \~\brief
//! \~english Defined when no dedicated compiler macro above matched.
//! \~russian Определяется, когда ни один специализированный макрос компилятора выше не подошел.
# define CC_OTHER
//! \~\ingroup Core
//! \~\brief
//! \~english Defined when POSIX signal APIs are expected to be available.
//! \~russian Определяется, когда ожидается доступность POSIX API сигналов.
# define POSIX_SIGNALS
#endif
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
# define WINDOWS
# define ARCH_BITS_64
#else
# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
# define WINDOWS
# define ARCH_BITS_32
# endif
#endif
#if defined(__QNX__) || defined(__QNXNTO__)
# define QNX
# ifdef Q_OS_BLACKBERRY
# define BLACKBERRY
# endif
#endif
#ifdef __FreeBSD__
# define FREE_BSD
#endif
#if defined(__APPLE__) || defined(__MACH__)
# define MAC_OS
#endif
#if defined(__ANDROID__) || defined(_ANDROID_) || defined(ANDROID)
# ifndef ANDROID
# define ANDROID
# endif
#endif
#ifdef PIP_FREERTOS
# define FREERTOS
#endif
#ifndef WINDOWS
# ifndef QNX
# ifndef FREE_BSD
# ifndef MAC_OS
# ifndef ANDROID
# ifndef BLACKBERRY
# ifndef FREERTOS
# ifndef PICO_SDK
# define LINUX
# endif
# endif
# endif
# endif
# endif
# endif
# endif
#endif
#ifndef WINDOWS
# if defined(__LP64__) || defined(_LP64_) || defined(LP64)
# define ARCH_BITS_64
# else
# define ARCH_BITS_32
# endif
#endif
#ifdef __GNUC__
# define CC_GCC
# define CC_GCC_VERSION ((__GNUC__ << 8) | __GNUC_MINOR__)
#elif defined(_MSC_VER)
# define CC_VC
#else
# define CC_OTHER
#endif
#ifdef __AVR__
# define CC_AVR_GCC
#endif
#ifdef WINDOWS
# ifdef CC_GCC
# define typeof __typeof
# endif
#else
# define typeof __typeof__
#endif
#if defined(LINUX) || defined(MAC_OS) || defined(ANDROID)
# define POSIX_SIGNALS
#endif
// Platform provides a text terminal (termios TTY) for console keyboard I/O
#if defined(LINUX) || defined(MAC_OS) || defined(ANDROID) || defined(QNX) || defined(FREE_BSD)
# define PIP_HAS_TTY
#endif
#endif // PIPLATFORM_H