1 /************************************************************************
2  **
3  **  @file   diagnostic.h
4  **  @author Roman Telezhynskyi <dismine(at)gmail.com>
5  **  @date   6 8, 2016
6  **
7  **  @brief
8  **  @copyright
9  **  This source code is part of the Valentina project, a pattern making
10  **  program, whose allow create and modeling patterns of clothing.
11  **  Copyright (C) 2016 Valentina project
12  **  <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
13  **
14  **  Valentina is free software: you can redistribute it and/or modify
15  **  it under the terms of the GNU General Public License as published by
16  **  the Free Software Foundation, either version 3 of the License, or
17  **  (at your option) any later version.
18  **
19  **  Valentina is distributed in the hope that it will be useful,
20  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  **  GNU General Public License for more details.
23  **
24  **  You should have received a copy of the GNU General Public License
25  **  along with Valentina.  If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #ifndef DIAGNOSTIC_H
30 #define DIAGNOSTIC_H
31 
32 #include <QtGlobal>
33 
34 #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
35 
36 /*
37  * Warning/diagnostic handling
38  */
39 
40 #define QT_DO_PRAGMA(text)                      _Pragma(#text)
41 #if defined(Q_CC_INTEL) && defined(Q_CC_MSVC)
42 /* icl.exe: Intel compiler on Windows */
43 #  undef QT_DO_PRAGMA                           /* not needed */
44 #  define QT_WARNING_PUSH                       __pragma(warning(push))
45 #  define QT_WARNING_POP                        __pragma(warning(pop))
46 #  define QT_WARNING_DISABLE_MSVC(number)
47 #  define QT_WARNING_DISABLE_INTEL(number)      __pragma(warning(disable: number))
48 #  define QT_WARNING_DISABLE_CLANG(text)
49 #  define QT_WARNING_DISABLE_GCC(text)
50 #elif defined(Q_CC_INTEL)
51 /* icc: Intel compiler on Linux or OS X */
52 #  define QT_WARNING_PUSH                       QT_DO_PRAGMA(warning(push))
53 #  define QT_WARNING_POP                        QT_DO_PRAGMA(warning(pop))
54 #  define QT_WARNING_DISABLE_INTEL(number)      QT_DO_PRAGMA(warning(disable: number))
55 #  define QT_WARNING_DISABLE_MSVC(number)
56 #  define QT_WARNING_DISABLE_CLANG(text)
57 #  define QT_WARNING_DISABLE_GCC(text)
58 #elif defined(Q_CC_MSVC) && _MSC_VER >= 1500
59 #  undef QT_DO_PRAGMA                           /* not needed */
60 #  define QT_WARNING_PUSH                       __pragma(warning(push))
61 #  define QT_WARNING_POP                        __pragma(warning(pop))
62 #  define QT_WARNING_DISABLE_MSVC(number)       __pragma(warning(disable: number))
63 #  define QT_WARNING_DISABLE_INTEL(number)
64 #  define QT_WARNING_DISABLE_CLANG(text)
65 #  define QT_WARNING_DISABLE_GCC(text)
66 #elif defined(Q_CC_CLANG)
67 #  define QT_WARNING_PUSH                       QT_DO_PRAGMA(clang diagnostic push)
68 #  define QT_WARNING_POP                        QT_DO_PRAGMA(clang diagnostic pop)
69 #  define QT_WARNING_DISABLE_CLANG(text)        QT_DO_PRAGMA(clang diagnostic ignored text)
70 #  define QT_WARNING_DISABLE_GCC(text)          QT_DO_PRAGMA(GCC diagnostic ignored text)   // GCC directives work in Clang too
71 #  define QT_WARNING_DISABLE_INTEL(number)
72 #  define QT_WARNING_DISABLE_MSVC(number)
73 #elif defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
74 #  define QT_WARNING_PUSH                       QT_DO_PRAGMA(GCC diagnostic push)
75 #  define QT_WARNING_POP                        QT_DO_PRAGMA(GCC diagnostic pop)
76 #  define QT_WARNING_DISABLE_GCC(text)          QT_DO_PRAGMA(GCC diagnostic ignored text)
77 #  define QT_WARNING_DISABLE_CLANG(text)
78 #  define QT_WARNING_DISABLE_INTEL(number)
79 #  define QT_WARNING_DISABLE_MSVC(number)
80 #else       // All other compilers, GCC < 4.6 and MSVC < 2008
81 #  define QT_WARNING_DISABLE_GCC(text)
82 #  define QT_WARNING_PUSH
83 #  define QT_WARNING_POP
84 #  define QT_WARNING_DISABLE_INTEL(number)
85 #  define QT_WARNING_DISABLE_MSVC(number)
86 #  define QT_WARNING_DISABLE_CLANG(text)
87 #  define QT_WARNING_DISABLE_GCC(text)
88 #endif
89 
90 #else
91 
92 #include <qcompilerdetection.h>
93 
94 #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
95 
96 #endif // DIAGNOSTIC_H
97