cake
/
libcasio
Archived
1
1
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libcasio/include/libcasio/cdefs.h

181 lines
4.8 KiB
C

/* ****************************************************************************
* libcasio/cdefs.h -- C helpers.
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
*
* This file is part of libcasio.
* libcasio 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.0 of the License,
* or (at your option) any later version.
*
* libcasio 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 libcasio; if not, see <http://www.gnu.org/licenses/>.
* ************************************************************************* */
/* Pre-ANSI C compilers don't support arguments (and argument types) in
* function declarations. This macro is inspired from zlib.
*
* It is defined outside of the include guard because it is not in
* the libcasio defined namespace, so we want it to be redefined, in case. */
#if defined(OF)
#elif defined(__STDC__) && __STDC__
# define OF(CASIO_ARGS) CASIO_ARGS
#else
# define OF(CASIO_ARGS) ()
#endif
/* "Normal start" of the file is here. */
#ifndef LIBCASIO_CDEFS_H
# define LIBCASIO_CDEFS_H
# include "config.h"
# include <stddef.h>
# include <time.h>
/* Check the library version. */
# define LIBCASIO_PREREQ(CASIO__MAJ, CASIO__MIN) \
((CASIO__MAJ) > (LIBCASIO_MAJOR) || \
((CASIO__MAJ) == (LIBCASIO_MAJOR) && (CASIO__MIN) >= (LIBCASIO_MINOR)))
/* ---
* Check for compilers.
* --- */
/* First, GCC. */
# if defined(CASIO_GNUC_PREREQ)
# elif defined(__GNUC__) && defined(__GNUC_MINOR__)
# define CASIO_GNUC_PREREQ(CASIO__MAJ, CASIO__MIN) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((CASIO__MAJ) << 16) + (CASIO__MIN))
# else
# define CASIO_GNUC_PREREQ(CASIO__MAJ, CASIO__MIN) 0
# endif
/* Then, Microsoft's Compiler. */
# if defined(CASIO_MSC_PREREQ) || defined(_MSC_VER)
# define CASIO_MSC_PREREQ(CASIO__MAJ, CASIO__MIN) \
(_MSC_VER >= (CASIO__MAJ) * 1000 + (CASIO__MIN))
# else
# define CASIO_MSC_PREREQ(CASIO__MAJ, CASIO__MIN) 0
# endif
/* ---
* Check for subsystems.
* --- */
/* Macros defined by the `libcasio/config.h` header:
* - `LIBCASIO_DISABLED_FILE`: can we use the standard FILE operations?
* - `LIBCASIO_DISABLED_LIBUSB`: can we use libusb? */
/* Can we use the Linux and the MacOS/OS X listing?
* XXX: what about Linux distributions not using the Linux standard
* filesystem? */
# if defined(__linux__)
# else
# define LIBCASIO_DISABLED_LINUX_SERIAL
# endif
# if defined(__APPLE__) && defined(__MACH__)
# else
# define LIBCASIO_DISABLED_MAC_SERIAL
# endif
/* Can we use the POSIX (STREAMS) interface? */
# if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
# else
# define LIBCASIO_DISABLED_STREAMS
# endif
/* Can we use the Windows (Win32/Win64) API? */
# if defined(_WIN16) || defined(_WIN32) || defined(_WIN64) \
|| defined(__WINDOWS__)
# else
# define LIBCASIO_DISABLED_WINDOWS
# endif
/* ---
* Extern functions.
* --- */
/* Some platforms require more than simply 'extern'.
* Here are macros to control this. */
# define CASIO_EXTERN extern
# define CASIO_EXPORT
# define CASIO_LOCAL static
/* ---
* Enumerations.
* --- */
/* Enumerations can be great thanks to the compiler: better warnings,
* better debug, better coding! */
# if defined(LIBCASIO_USE_ENUMS)
# elif defined(__STDC__) && __STDC__
# define LIBCASIO_USE_ENUMS 1
# else /* K&R C, no enums! */
# define LIBCASIO_USE_ENUMS 0
# endif
/* ---
* C++ declarations and namespaces management.
* --- */
/* libcasio is made in C. */
# if 0 /* hey, what about this? */
# define CASIO_BEGIN_NAMESPACE namespace casio {
# define CASIO_END_NAMESPACE }
# endif
# ifdef __cplusplus
# define CASIO_BEGIN_NAMESPACE
# define CASIO_BEGIN_DECLS extern "C" {
# define CASIO_END_DECLS }
# define CASIO_END_NAMESPACE
# else
# define CASIO_BEGIN_NAMESPACE
# define CASIO_BEGIN_DECLS
# define CASIO_END_DECLS
# define CASIO_END_NAMESPACE
# endif
/* ---
* Various function attributes.
* --- */
/* Warn if the result is unused.
* To do that, we'll use the `CASIO_WUR` attribute. */
# if CASIO_GNUC_PREREQ(4, 0)
# define CASIO_WUR __attribute__((warn_unused_result))
# elif CASIO_MSC_PREREQ(17, 0)
# include <sal.h>
# define CASIO_WUR _Check_return_
# else
# define CASIO_WUR
# endif
/* Warn if the function is deprecated. */
# if CASIO_GNUC_PREREQ(3, 0)
# define CASIO_DEPRECATED __attribute__((deprecated))
# else
# define CASIO_DEPRECATED
# endif
# include "cdefs/integers.h"
# include "cdefs/endian.h"
#endif /* LIBCASIO_CDEFS_H */