Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CTK pragma macros and fix "PythonQtInstanceWrapper.h" -Wold-style-cast warnings #837

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMake/ctkWrapPythonQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,21 @@ def ctk_wrap_pythonqt(target, namespace, output_dir, input_files, extra_verbose)
// File auto-generated by ctkWrapPythonQt.py
//

#include "ctkMacro.h"

#ifdef CTK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
CTK_GCC_PRAGMA_DIAG_PUSH()
#endif
CTK_GCC_PRAGMA_DIAG(ignored "-Wold-style-cast")

#include <PythonQt.h>

#ifdef CTK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
CTK_GCC_PRAGMA_DIAG_POP()
#else
CTK_GCC_PRAGMA_DIAG(warning "-Wold-style-cast")
#endif

// XXX Avoid warning: "HAVE_XXXX" redefined
#undef HAVE_STAT
#undef HAVE_FTIME
Expand Down
49 changes: 49 additions & 0 deletions Libs/Core/ctkMacro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifndef __ctkMacro_h
#define __ctkMacro_h

// Define CTK_PRAGMA macro.
//
// It sets "#pragma" preprocessor directives without expecting the arguments
// to be quoted.
#define CTK_PRAGMA(x) _Pragma (#x)

// Define CTK_GCC_PRAGMA_DIAG(param1 [param2 [...]]) macro.
//
// This macros sets a pragma diagnostic if it supported by the version
// of GCC being used otherwise it is a no-op.
//
// GCC diagnostics pragma supported only with GCC >= 4.2
#if defined( __GNUC__ ) && !defined( __INTEL_COMPILER )
# if ( __GNUC__ > 4 ) || (( __GNUC__ >= 4 ) && ( __GNUC_MINOR__ >= 2 ))
# define CTK_GCC_PRAGMA_DIAG(x) CTK_PRAGMA(GCC diagnostic x)
# else
# define CTK_GCC_PRAGMA_DIAG(x)
# endif
#else
# define CTK_GCC_PRAGMA_DIAG(x)
#endif

// Define CTK_GCC_PRAGMA_DIAG_(PUSH|POP) macros.
//
// These macros respectively push and pop the diagnostic context
// if it is supported by the version of GCC being used
// otherwise it is a no-op.
//
// GCC push/pop diagnostics pragma are supported only with GCC >= 4.6
//
// Define macro CTK_HAS_GCC_PRAGMA_DIAG_PUSHPOP if it is supported.
#if defined( __GNUC__ ) && !defined( __INTEL_COMPILER )
# if ( __GNUC__ > 4 ) || (( __GNUC__ >= 4 ) && ( __GNUC_MINOR__ >= 6 ))
# define CTK_GCC_PRAGMA_DIAG_PUSH() CTK_GCC_PRAGMA_DIAG(push)
# define CTK_GCC_PRAGMA_DIAG_POP() CTK_GCC_PRAGMA_DIAG(pop)
# define CTK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
# else
# define CTK_GCC_PRAGMA_DIAG_PUSH()
# define CTK_GCC_PRAGMA_DIAG_POP()
# endif
#else
# define CTK_GCC_PRAGMA_DIAG_PUSH()
# define CTK_GCC_PRAGMA_DIAG_POP()
#endif

#endif