mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 20:19:53 +00:00
bbbdf54a35
The FundamentalType header needs to know type sizes at preprocessing time. This commit teaches it to avoid using CHECK_TYPE_SIZE because the macro does not work for types whose size varies across architectuers in Mac OS X universal binaries. Fortunately the Mac compilers provide just enough information to detect the needed type sizes during preprocessing. We now use preprocessor macros instead of configuration tests whenever they are available. As a side effect this reduces the number of try-compiles needed with GCC. See issue #9913.
101 lines
2.4 KiB
C
101 lines
2.4 KiB
C
/*============================================================================
|
|
KWSys - Kitware System Library
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
See the License for more information.
|
|
============================================================================*/
|
|
/*
|
|
Macros to define main() in a cross-platform way.
|
|
|
|
Usage:
|
|
|
|
int KWSYS_PLATFORM_TEST_C_MAIN()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv)
|
|
{
|
|
(void)argc; (void)argv;
|
|
return 0;
|
|
}
|
|
*/
|
|
#if defined(__CLASSIC_C__)
|
|
# define KWSYS_PLATFORM_TEST_C_MAIN() \
|
|
main()
|
|
# define KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv) \
|
|
main(argc,argv) int argc; char* argv[];
|
|
#else
|
|
# define KWSYS_PLATFORM_TEST_C_MAIN() \
|
|
main(void)
|
|
# define KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv) \
|
|
main(int argc, char* argv[])
|
|
#endif
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
#ifdef TEST_KWSYS_C_HAS_PTRDIFF_T
|
|
#include <stddef.h>
|
|
int f(ptrdiff_t n) { return n > 0; }
|
|
int KWSYS_PLATFORM_TEST_C_MAIN()
|
|
{
|
|
char* p = 0;
|
|
ptrdiff_t d = p - p;
|
|
(void)d;
|
|
return f(p - p);
|
|
}
|
|
#endif
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
#ifdef TEST_KWSYS_C_HAS_SSIZE_T
|
|
#include <unistd.h>
|
|
int f(ssize_t n) { return (int)n; }
|
|
int KWSYS_PLATFORM_TEST_C_MAIN()
|
|
{
|
|
ssize_t n = 0;
|
|
return f(n);
|
|
}
|
|
#endif
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
#ifdef TEST_KWSYS_C_TYPE_MACROS
|
|
char* info_macros =
|
|
#if defined(__SIZEOF_SHORT__)
|
|
"INFO:macro[__SIZEOF_SHORT__]\n"
|
|
#endif
|
|
#if defined(__SIZEOF_INT__)
|
|
"INFO:macro[__SIZEOF_INT__]\n"
|
|
#endif
|
|
#if defined(__SIZEOF_LONG__)
|
|
"INFO:macro[__SIZEOF_LONG__]\n"
|
|
#endif
|
|
#if defined(__SIZEOF_LONG_LONG__)
|
|
"INFO:macro[__SIZEOF_LONG_LONG__]\n"
|
|
#endif
|
|
#if defined(__SHORT_MAX__)
|
|
"INFO:macro[__SHORT_MAX__]\n"
|
|
#endif
|
|
#if defined(__INT_MAX__)
|
|
"INFO:macro[__INT_MAX__]\n"
|
|
#endif
|
|
#if defined(__LONG_MAX__)
|
|
"INFO:macro[__LONG_MAX__]\n"
|
|
#endif
|
|
#if defined(__LONG_LONG_MAX__)
|
|
"INFO:macro[__LONG_LONG_MAX__]\n"
|
|
#endif
|
|
"";
|
|
|
|
int KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv)
|
|
{
|
|
int require = 0;
|
|
require += info_macros[argc];
|
|
(void)argv;
|
|
return require;
|
|
}
|
|
#endif
|