PLaSK library

Loading...
Searching...
No Matches
warnings.hpp
Go to the documentation of this file.
1/*
2 * This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3 * Copyright (c) 2022 Lodz University of Technology
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14#ifndef PLASK_WARNINGS_H
15#define PLASK_WARNINGS_H
16
21#ifdef _MSC_VER
22 #define PLASK_PRAGMA(x) __pragma(x) // MSVC does not implement standard _Pragma but has own extension __pragma
23#else
25 #define PLASK_PRAGMA(x) _Pragma(#x)
26#endif
27
28// this helps disable warning about unusing parameter in doxygen-friendly way
29#ifdef DOXYGEN
31 #define PLASK_UNUSED(arg) arg
32#else
33 #define PLASK_UNUSED(arg)
34#endif
35
36
37
38#ifdef _MSC_VER // ----------- Visual C++ -----------
39
40#define PLASK_NO_CONVERSION_WARNING_BEGIN \
41 PLASK_PRAGMA(warning(push)) \
42 PLASK_PRAGMA(warning(disable: 4244))
43
44#define PLASK_NO_UNUSED_VARIABLE_WARNING_BEGIN \
45 PLASK_PRAGMA(warning(push)) \
46 PLASK_PRAGMA(warning(disable: 4101))
47
48#define PLASK_NO_WARNING_END \
49 PLASK_PRAGMA(warning(pop))
50
51#elif defined(__GNUC__) // ----------- GNU C++ -----------
52
53#define PLASK_NO_CONVERSION_WARNING_BEGIN \
54 PLASK_PRAGMA(GCC diagnostic push) \
55 PLASK_PRAGMA(GCC diagnostic ignored "-Wconversion")
56
57#define PLASK_NO_UNUSED_VARIABLE_WARNING_BEGIN \
58 PLASK_PRAGMA(GCC diagnostic push) \
59 PLASK_PRAGMA(GCC diagnostic ignored "-Wunused-variable")
60
61#define PLASK_NO_WARNING_END \
62 PLASK_PRAGMA(GCC diagnostic pop)
63
64#elif defined(__clang__) // ----------- Clang -----------
65
66#define PLASK_NO_CONVERSION_WARNING_BEGIN \
67 PLASK_PRAGMA(clang diagnostic push) \
68 PLASK_PRAGMA(clang diagnostic ignored "-Wconversion")
69
70#define PLASK_NO_UNUSED_VARIABLE_WARNING_BEGIN \
71 PLASK_PRAGMA(clang diagnostic push) \
72 PLASK_PRAGMA(clang diagnostic ignored "-Wunused-variable")
73
74#define PLASK_NO_WARNING_END \
75 PLASK_PRAGMA(clang diagnostic pop)
76
77#else // ----------- unknown compiler -----------
78
80#define PLASK_NO_CONVERSION_WARNING_BEGIN
81
83#define PLASK_NO_UNUSED_VARIABLE_WARNING_BEGIN
84
86#define PLASK_NO_WARNING_END
87
88#endif
89
90#endif // PLASK_WARNINGS_H