ソースを参照

base: add a features.h header.

wip/core-clipp
Sam Hocevar 4年前
コミット
742bb53bdd
4個のファイルの変更52行の追加43行の削除
  1. +47
    -0
      include/lol/base/features.h
  2. +2
    -0
      include/lol/base/string.h
  3. +3
    -1
      include/lol/math/real.h
  4. +0
    -42
      legacy/lol/base/features.h

+ 47
- 0
include/lol/base/features.h ファイルの表示

@@ -0,0 +1,47 @@
//
// Lol Engine
//
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#pragma once

//
// The build-time features
// ———————————————————————
//

// C++ compiler features detected through __has_cpp_attribute

#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
# define LOL_ATTR_NODISCARD [[nodiscard]]
#else
# define LOL_ATTR_NODISCARD /* */
#endif

#if defined(__has_cpp_attribute) && __has_cpp_attribute(fallthrough)
# define LOL_ATTR_FALLTHROUGH [[fallthrough]];
#else
# define LOL_ATTR_FALLTHROUGH /* */
#endif

// Define some attribute macros.

#ifdef __GNUC__
# define LOL_ATTR_FORMAT(n, p) __attribute__((format(printf, n, p)))
#else
# define LOL_ATTR_FORMAT(n, p)
#endif

#if defined(_WIN32)
# define LOL_ATTR_STDCALL __stdcall
#else
# define LOL_ATTR_STDCALL /* */
#endif


+ 2
- 0
include/lol/base/string.h ファイルの表示

@@ -19,6 +19,8 @@
// Contains some utilities to work with std::string objects.
//

#include <lol/base/features.h>

#include <vector>
#include <string>
#include <algorithm> // std::transform


+ 3
- 1
include/lol/math/real.h ファイルの表示

@@ -14,9 +14,11 @@

//
// The Real class
// --------------
// ——————————————
//

#include <lol/base/features.h>

#include <vector>
#include <string>
#include <cstdint>


+ 0
- 42
legacy/lol/base/features.h ファイルの表示

@@ -28,19 +28,6 @@
#undef LOL_FEATURE_CXX11_TEMPLATE_ALIASES
#undef LOL_FEATURE_CXX11_SFINAE_FOR_CTORS

#undef LOL_FEATURE_CXX17_ATTRIBUTE_NODISCARD
#undef LOL_FEATURE_CXX17_ATTRIBUTE_FALLTHROUGH

/* Features detected through __has_cpp_attribute */
#ifdef __has_cpp_attribute
# if __has_cpp_attribute(nodiscard)
# define LOL_FEATURE_CXX17_ATTRIBUTE_NODISCARD 1
# endif
# if __has_cpp_attribute(fallthrough)
# define LOL_FEATURE_CXX17_ATTRIBUTE_FALLTHROUGH 1
# endif
#endif

/* Features supported by GCC */
#if defined __GNUC__
# if !defined(__GXX_EXPERIMENTAL_CXX0X) && __cplusplus < 201103L
@@ -82,35 +69,6 @@
#endif


/*
* Define some attribute macros.
*/

#ifdef __GNUC__
# define LOL_ATTR_FORMAT(n, p) __attribute__((format(printf, n, p)))
#else
# define LOL_ATTR_FORMAT(n, p)
#endif

#if defined(_WIN32)
# define LOL_ATTR_STDCALL __stdcall
#else
# define LOL_ATTR_STDCALL /* */
#endif

#ifdef LOL_FEATURE_CXX17_ATTRIBUTE_NODISCARD
# define LOL_ATTR_NODISCARD [[nodiscard]]
#else
# define LOL_ATTR_NODISCARD /* */
#endif

#ifdef LOL_FEATURE_CXX17_ATTRIBUTE_FALLTHROUGH
# define LOL_ATTR_FALLTHROUGH [[fallthrough]];
#else
# define LOL_ATTR_FALLTHROUGH /* */
#endif


/*
* Ensure we have ptrdiff_t.
*/


読み込み中…
キャンセル
保存