Archived issue #0029128

Cross-platform macro for enabling compiler warnings suppressed by third-party products

Open CASCADEOCCT:Codingclosed3 public notes

Search issues

Description

As mentioned in comment #0028452, we sometimes have to deal with compiler warnings suppressed by third-party headers included in some OCCT or application source file. As a result, warnings resulted from the source file itself are also suppressed - this results in decreased OCCT/application code quality.

Quick solution implemented in issue #0028452 is to use #pragma warning(push) before the third-party headers and #pragma warning(pop) right after it. This is a Microsoft-specific solution.
So it is preferred to define a reusable pair of macros for pushing/popping warnings - see "#pragma GCC diagnostic push/pop" available in gcc 4.6+ and similar commands in CLang.

For convenience and work optimization, it is proposed to put these macros to some common header in OCCT to make them available to OCCT-based applications.

Public activity

3 archived notes

Participants are labeled by their role within this record.

01Commenter 1
Sergey, I'm afraid that we cannot create a macro like you proposed. The problem is that you cannot define a macro containing preprocessor directive -- this will not work (preprocessor is one-pass, and # inside a macro is stringizing operator).

It could be possible to put this kind of macros in header file(s), and #include it (them) to trigger the warnings,.. but do we want that?
02Commenter 2
With g++ there is the possibility to add an include path with "-isystem" instead of "-I". Then no warnings are printed from those include files.
03Commenter 3
The new headers Standard_WarningsDisable.hxx and Standard_WarningsRestore.hxx implementing this feature have been added within #0029310 and #0029909

Related records