Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
DLR-AMR
GitHub Repository: DLR-AMR/t8code
Path: blob/main/src/t8_with_macro_error.h
898 views
1
/*
2
This file is part of t8code.
3
t8code is a C library to manage a collection (a forest) of multiple
4
connected adaptive space-trees of general element classes in parallel.
5
6
Copyright (C) 2025 the developers
7
8
t8code is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
12
13
t8code is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with t8code; if not, write to the Free Software Foundation, Inc.,
20
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
*/
22
23
/** \file t8_with_macro_error.h
24
* This file defines macros to cause an error in user code when using
25
* deprecated "T8_WITH_*" macros.
26
* Unfortunately, the error will not be raised in \#ifdef constructions (This is still an open TODO.).
27
* With https://github.com/DLR-AMR/t8code/issues/1370 we switched all our macros
28
* that control settings and external libraries to "T8_ENABLE_*".
29
* Users might not have implmented that change and left "T8_WITH_*" in their code.
30
* This could lead to unintentionally behaviour if the macros are ignored even if the
31
* setting would have been enabled.
32
* Hence, we define a macro that throws an error, whenever a "T8_WITH_*" is called.
33
* This macro is defined for each "T8_ENABLE_*" option.
34
*/
35
36
#ifndef T8_WITH_MACRO_ERROR_H
37
#define T8_WITH_MACRO_ERROR_H
38
39
// clang-format off
40
// Since we use a symbol that is not part of C/C++ syntax, clang-format would not indent the file.
41
/** This macro defines the macro "T8_THROW_ERROR_WITH" to cause an error
42
* whenever it is evaluated. Including \#if usage. (But not including \#ifdef usage).
43
* Example usage:
44
* \#define T8_WITH_DEBUG T8_THROW_ERROR_WITH
45
*
46
* Using this with
47
* \#if T8_WITH_DEBUG
48
* will throw a compile-time error.
49
*/
50
#define T8_THROW_ERROR_WITH @"Invalid usage of T8_WITH_*. Use T8_ENABLE_* instead."
51
// clang-format on
52
53
// We would like to use \#error here to cause a compile time error message,
54
// however, expanding "\#error" in macros is not supported.
55
// Instead, we use the symbol "@" which is not part of C/C++ syntax and will throw
56
// an error when evaluated. See also https://stackoverflow.com/questions/21055507/forcing-preprocessor-error-with-macro
57
58
// We now define all T8_ENABLE_* macros that existed at 28 March 2025 to throw an error
59
// when called in a T8_WITH_* version.
60
#define T8_WITH_DEBUG T8_THROW_ERROR_WITH /**< Deprecated debug macro, will produce an error when used with \#if. */
61
#define T8_WITH_VTK T8_THROW_ERROR_WITH /**< Deprecated vtk macro, will produce an error when used with \#if. */
62
#define T8_WITH_OCC T8_THROW_ERROR_WITH /**< Deprecated occ macro, will produce an error when used with \#if. */
63
#define T8_WITH_METIS T8_THROW_ERROR_WITH /**< Deprecated metis macro, will produce an error when used with \#if. */
64
#define T8_WITH_MPI T8_THROW_ERROR_WITH /**< Deprecated MPI macro, will produce an error when used with \#if. */
65
#define T8_WITH_MPIIO T8_THROW_ERROR_WITH /**< Deprecated MPIIO macro, will produce an error when used with \#if. */
66
#define T8_WITH_FORTRAN T8_THROW_ERROR_WITH /**< Deprecated FORTRAN macro, will produce an error when used with \#if. */
67
#define T8_WITH_CPPSTD T8_THROW_ERROR_WITH /**< Deprecated cppstd macro, will produce an error when used with \#if. */
68
#define T8_WITH_MODDIR T8_THROW_ERROR_WITH /**< Deprecated moddir macro, will produce an error when used with \#if. */
69
#define T8_WITH_CUSTOM_TEST_COMMAND T8_THROW_ERROR_WITH /**< Deprecated custom_test_command macro, will produce an error when used with \#if. */
70
71
#endif // T8_WITH_MACRO_ERROR_H
72
73