blob: 367a44d366a7485cff9601ed1ff1ed39f354072e [file] [log] [blame]
Austin Schuh0cbef622015-09-06 17:34:52 -07001// Copyright 2008, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Austin Schuh889ac432018-10-29 22:57:02 -070029
Austin Schuh0cbef622015-09-06 17:34:52 -070030//
31// Low-level types and utilities for porting Google Mock to various
32// platforms. All macros ending with _ and symbols defined in an
33// internal namespace are subject to change without notice. Code
34// outside Google Mock MUST NOT USE THEM DIRECTLY. Macros that don't
35// end with _ are part of Google Mock's public API and can be used by
36// code outside Google Mock.
37
Austin Schuh889ac432018-10-29 22:57:02 -070038// GOOGLETEST_CM0002 DO NOT DELETE
39
James Kuszmaule2f15292021-05-10 22:37:32 -070040#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
41#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
Austin Schuh0cbef622015-09-06 17:34:52 -070042
43#include <assert.h>
44#include <stdlib.h>
James Kuszmaule2f15292021-05-10 22:37:32 -070045#include <cstdint>
Austin Schuh0cbef622015-09-06 17:34:52 -070046#include <iostream>
47
48// Most of the utilities needed for porting Google Mock are also
49// required for Google Test and are defined in gtest-port.h.
50//
51// Note to maintainers: to reduce code duplication, prefer adding
52// portability utilities to Google Test's gtest-port.h instead of
53// here, as Google Mock depends on Google Test. Only add a utility
54// here if it's truly specific to Google Mock.
Austin Schuh889ac432018-10-29 22:57:02 -070055
Austin Schuh0cbef622015-09-06 17:34:52 -070056#include "gtest/internal/gtest-port.h"
57#include "gmock/internal/custom/gmock-port.h"
58
James Kuszmaule2f15292021-05-10 22:37:32 -070059// For MS Visual C++, check the compiler version. At least VS 2015 is
Austin Schuh0cbef622015-09-06 17:34:52 -070060// required to compile Google Mock.
James Kuszmaule2f15292021-05-10 22:37:32 -070061#if defined(_MSC_VER) && _MSC_VER < 1900
62# error "At least Visual C++ 2015 (14.0) is required to compile Google Mock."
Austin Schuh0cbef622015-09-06 17:34:52 -070063#endif
64
65// Macro for referencing flags. This is public as we want the user to
66// use this syntax to reference Google Mock flags.
67#define GMOCK_FLAG(name) FLAGS_gmock_##name
68
69#if !defined(GMOCK_DECLARE_bool_)
70
71// Macros for declaring flags.
Austin Schuh889ac432018-10-29 22:57:02 -070072# define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)
James Kuszmaule2f15292021-05-10 22:37:32 -070073# define GMOCK_DECLARE_int32_(name) extern GTEST_API_ int32_t GMOCK_FLAG(name)
Austin Schuh889ac432018-10-29 22:57:02 -070074# define GMOCK_DECLARE_string_(name) \
Austin Schuh0cbef622015-09-06 17:34:52 -070075 extern GTEST_API_ ::std::string GMOCK_FLAG(name)
76
77// Macros for defining flags.
Austin Schuh889ac432018-10-29 22:57:02 -070078# define GMOCK_DEFINE_bool_(name, default_val, doc) \
Austin Schuh0cbef622015-09-06 17:34:52 -070079 GTEST_API_ bool GMOCK_FLAG(name) = (default_val)
Austin Schuh889ac432018-10-29 22:57:02 -070080# define GMOCK_DEFINE_int32_(name, default_val, doc) \
James Kuszmaule2f15292021-05-10 22:37:32 -070081 GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val)
Austin Schuh889ac432018-10-29 22:57:02 -070082# define GMOCK_DEFINE_string_(name, default_val, doc) \
Austin Schuh0cbef622015-09-06 17:34:52 -070083 GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
84
85#endif // !defined(GMOCK_DECLARE_bool_)
86
James Kuszmaule2f15292021-05-10 22:37:32 -070087#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_