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 // TODO może C4101 ?
47
48#define PLASK_NO_WARNING_END \
49 PLASK_PRAGMA(warning(pop))
50
51
52
53#elif defined(__GNUC__) // ----------- GNU C++ -----------
54
55#define PLASK_NO_CONVERSION_WARNING_BEGIN \
56 PLASK_PRAGMA(GCC diagnostic push) \
57 PLASK_PRAGMA(GCC diagnostic ignored "-Wconversion")
58
59#define PLASK_NO_UNUSED_VARIABLE_WARNING_BEGIN \
60 PLASK_PRAGMA(GCC diagnostic push) \
61 PLASK_PRAGMA(GCC diagnostic ignored "-Wunused-variable")
62
63#define PLASK_NO_WARNING_END \
64 PLASK_PRAGMA(GCC diagnostic pop)
65
66
67
68#else // ----------- unknown compiler -----------
69
71#define PLASK_NO_CONVERSION_WARNING_BEGIN
72
74#define PLASK_NO_UNUSED_VARIABLE_WARNING_BEGIN
75
77#define PLASK_NO_WARNING_END
78
79#endif
80
81#endif // PLASK_WARNINGS_H