Skip to content

Commit

Permalink
Move Extensions.h
Browse files Browse the repository at this point in the history
  • Loading branch information
flagarde committed May 16, 2024
1 parent 5a15a47 commit 2c28154
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 44 deletions.
30 changes: 3 additions & 27 deletions include/Khaos/details/languages/C.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,12 @@
*/

#include "Khaos/details/languages/CStandards.h"
#include "Khaos/details/languages/Extensions.h"

#if defined(__STDC_VERSION__)
#define KHAOS_C_STANDARD_PRIVATE() (__STDC_VERSION__) /* //NOSONAR !< defined as __STDC_VERSION__ */
#define KHAOS_C_STANDARD_PRIVATE() (__STDC_VERSION__) /*!< defined as __STDC_VERSION__ */
#else
#define KHAOS_C_STANDARD_PRIVATE() KHAOS_STANDARD_C90_PRIVATE() /* //NOSONAR !< defined as C90 */
#endif

/*
The compiler uses C compilation mode by default when a source file has a .c extension, or when the /Tc or /TC option is specified.
The C compiler is an C89/C90 compiler that, by default, enables Microsoft extensions to the C language.
For more information about specific extensions, see Microsoft Extensions to C and C++.
When both C compilation and the /Za option are specified, the C compiler conforms strictly to the C89/C90 standard.
The compiler treats Microsoft extended keywords as simple identifiers, disables the other Microsoft extensions, and automatically defines the __STDC__ predefined macro for C programs.
The default C compiler (that is, the compiler when /std:c11 or /std:c17 isn't specified) implements ANSI C89, but includes several Microsoft extensions, some of which are part of ISO C99.
Some Microsoft extensions to C89 can be disabled by using the /Za compiler option, but others remain in effect. It isn't possible to specify strict C89 conformance.
The compiler doesn't implement several required features of C99, so it isn't possible to specify C99 conformance, either.
The /std:c11 option enables ISO C11 conformance. It's available starting in Visual Studio 2019 version 16.8.
The /std:c17 option enables ISO C17 conformance. It's available starting in Visual Studio 2019 version 16.8.
Because the new preprocessor is needed to support these standards, the /std:c11 and /std:c17 compiler options set the /Zc:preprocessor option automatically.
If you want to use the traditional (legacy) preprocessor for C11 or C17, you must set the /Zc:preprocessor- compiler option explicitly.
Setting the /Zc:preprocessor- option may lead to unexpected behavior, and isn't recommended.
*/

#if defined(__STRICT_ANSI__) || defined(__ANSI__) || defined(NO_EXT_KEYS)
#define KHAOS_LANGUAGE_ISO_PRIVATE() (1L) /* //NOSONAR !< 1 if strict ISO, 0 otherwise */
#define KHAOS_LANGUAGE_Extensions_PRIVATE() (0L) /* //NOSONAR !< 0 if strict ISO, 1 otherwise */
#else
#define KHAOS_LANGUAGE_ISO_PRIVATE() (0L) /* //NOSONAR !< 1 if strict ISO, 0 otherwise */
#define KHAOS_LANGUAGE_Extensions_PRIVATE() (1L) /* //NOSONAR !< 0 if strict ISO, 1 otherwise */
#define KHAOS_C_STANDARD_PRIVATE() KHAOS_STANDARD_C90_PRIVATE() /*!< defined as C90 */
#endif

#endif /* KHAOS_C_H_ */
15 changes: 4 additions & 11 deletions include/Khaos/details/languages/CXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include "Khaos/details/languages/CXXStandards.h"
#include "Khaos/details/languages/Extensions.h"

#if defined(_MSC_VER)
/*!
Expand All @@ -28,20 +29,12 @@
*
*/
#if defined(_MSVC_LANG)
#define KHAOS_CXX_STANDARD_PRIVATE() (_MSVC_LANG) /* //NOSONAR !< defined as _MSVC_LANG */
#define KHAOS_CXX_STANDARD_PRIVATE() (_MSVC_LANG) /*!< defined as _MSVC_LANG */
#else
#define KHAOS_CXX_STANDARD_PRIVATE() (__cplusplus) /* //NOSONAR !< defined as __cplusplus */
#define KHAOS_CXX_STANDARD_PRIVATE() (__cplusplus) /*!< defined as __cplusplus */
#endif
#else
#define KHAOS_CXX_STANDARD_PRIVATE() (__cplusplus) /* //NOSONAR !< defined as __cplusplus */
#endif

#if defined(__STRICT_ANSI__) || defined(__ANSI__) || defined(NO_EXT_KEYS)
#define KHAOS_LANGUAGE_ISO_PRIVATE() (1L) /* //NOSONAR !< 1 if strict ISO, 0 otherwise */
#define KHAOS_LANGUAGE_Extensions_PRIVATE() (0L) /* //NOSONAR !< 0 if strict ISO, 1 otherwise */
#else
#define KHAOS_LANGUAGE_ISO_PRIVATE() (0L) /* //NOSONAR !< 1 if strict ISO, 0 otherwise */
#define KHAOS_LANGUAGE_Extensions_PRIVATE() (1L) /* //NOSONAR !< 0 if strict ISO, 1 otherwise */
#define KHAOS_CXX_STANDARD_PRIVATE() (__cplusplus) /*!< defined as __cplusplus */
#endif

#endif /* KHAOS_CXX_H_ */
12 changes: 6 additions & 6 deletions include/Khaos/details/languages/CXXStandards.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* Official values for the \b __cplusplus macro.
*/

#define KHAOS_STANDARD_CXX98_PRIVATE() (199711L) /* //NOSONAR !< Value for the C++97 standard */
#define KHAOS_STANDARD_CXX11_PRIVATE() (201103L) /* //NOSONAR !< Value for the C++11 standard */
#define KHAOS_STANDARD_CXX14_PRIVATE() (201402L) /* //NOSONAR !< Value for the C++14 standard */
#define KHAOS_STANDARD_CXX17_PRIVATE() (201703L) /* //NOSONAR !< Value for the C++17 standard */
#define KHAOS_STANDARD_CXX20_PRIVATE() (202002L) /* //NOSONAR !< Value for the C++20 standard */
#define KHAOS_STANDARD_CXX23_PRIVATE() (202302L) /* //NOSONAR !< Value for the C++23 standard */
#define KHAOS_STANDARD_CXX98_PRIVATE() (199711L) /*!< Value for the C++97 standard */
#define KHAOS_STANDARD_CXX11_PRIVATE() (201103L) /*!< Value for the C++11 standard */
#define KHAOS_STANDARD_CXX14_PRIVATE() (201402L) /*!< Value for the C++14 standard */
#define KHAOS_STANDARD_CXX17_PRIVATE() (201703L) /*!< Value for the C++17 standard */
#define KHAOS_STANDARD_CXX20_PRIVATE() (202002L) /*!< Value for the C++20 standard */
#define KHAOS_STANDARD_CXX23_PRIVATE() (202302L) /*!< Value for the C++23 standard */

#endif /* KHAOS_CXX_STANDARDS_H_ */
21 changes: 21 additions & 0 deletions include/Khaos/details/languages/Extensions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Khaos
* C/C++ library for writing cross-platform codes.
*
* SPDX-FileCopyrightText: 2020-2024 flagarde
*
* SPDX-License-Identifier: MIT
*/

#ifndef KHAOS_EXTENSIONS_H_
#define KHAOS_EXTENSIONS_H_

#if defined(__STRICT_ANSI__) || defined(__ANSI__) || defined(NO_EXT_KEYS)
#define KHAOS_LANGUAGE_ISO_PRIVATE() (1L) /*!< 1 if strict ISO, 0 otherwise */
#define KHAOS_LANGUAGE_Extensions_PRIVATE() (0L) /*!< 0 if strict ISO, 1 otherwise */
#else
#define KHAOS_LANGUAGE_ISO_PRIVATE() (0L) /*!< 1 if strict ISO, 0 otherwise */
#define KHAOS_LANGUAGE_Extensions_PRIVATE() (1L) /*!< 0 if strict ISO, 1 otherwise */
#endif

#endif /* KHAOS_EXTENSIONS_H_ */

0 comments on commit 2c28154

Please sign in to comment.