CppUTest
CppUTestConfig.h
1 /*
2  * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the <organization> nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 
29 #ifndef CPPUTESTCONFIG_H_
30 #define CPPUTESTCONFIG_H_
31 
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35 
36 /*
37  * This file is added for some specific CppUTest configurations that earlier were spread out into multiple files.
38  *
39  * The goal of this file is to stay really small and not to include other things, but mainly to remove duplication
40  * from other files and resolve dependencies in #includes.
41  *
42  */
43 
44 /*
45  * Lib C dependencies that are currently still left:
46  *
47  * stdarg.h -> We use formatting functions and va_list requires to include stdarg.h in SimpleString
48  * stdlib.h -> The TestHarness_c.h includes this to try to avoid conflicts in its malloc #define. This dependency can
49  * easily be removed by not enabling the MALLOC overrides.
50  *
51  * Lib C++ dependencies are all under the CPPUTEST_USE_STD_CPP_LIB.
52  * The only dependency is to <new> which has the bad_alloc struct
53  *
54  */
55 
56 /* Do we use Standard C or not? When doing Kernel development, standard C usage is out. */
57 #ifndef CPPUTEST_USE_STD_C_LIB
58  #ifdef CPPUTEST_STD_C_LIB_DISABLED
59  #define CPPUTEST_USE_STD_C_LIB 0
60  #else
61  #define CPPUTEST_USE_STD_C_LIB 1
62  #endif
63 #endif
64 
65 
66 /* Do we use Standard C++ or not? */
67 #ifndef CPPUTEST_USE_STD_CPP_LIB
68  #ifdef CPPUTEST_STD_CPP_LIB_DISABLED
69  #define CPPUTEST_USE_STD_CPP_LIB 0
70  #else
71  #define CPPUTEST_USE_STD_CPP_LIB 1
72  #endif
73 #endif
74 
75 /* Is memory leak detection enabled?
76  * Controls the override of the global operator new/deleted and malloc/free.
77  * Without this, there will be no memory leak detection in C/C++.
78 */
79 
80 #ifndef CPPUTEST_USE_MEM_LEAK_DETECTION
81  #ifdef CPPUTEST_MEM_LEAK_DETECTION_DISABLED
82  #define CPPUTEST_USE_MEM_LEAK_DETECTION 0
83  #else
84  #define CPPUTEST_USE_MEM_LEAK_DETECTION 1
85  #endif
86 #endif
87 
88 /* Create a __no_return__ macro, which is used to flag a function as not returning.
89  * Used for functions that always throws for instance.
90  *
91  * This is needed for compiling with clang, without breaking other compilers.
92  */
93 #ifndef __has_attribute
94  #define __has_attribute(x) 0
95 #endif
96 #if __has_attribute(noreturn)
97  #define __no_return__ __attribute__((noreturn))
98 #else
99  #define __no_return__
100 #endif
101 
102 /* Should be the only #include here. Standard C library wrappers */
103 #include "StandardCLibrary.h"
104 
105 #endif