COIN-OR::LEMON - Graph Library

Opened 15 years ago

Closed 15 years ago

#295 closed enhancement (done)

Suppress VS warnings using pragmas instead of compiler options

Reported by: Alpar Juttner Owned by: Akos Ladanyi
Priority: major Milestone: LEMON 1.2 release
Component: build system Version: hg main
Keywords: Cc:
Revision id:

Description

Currently, the unavoidable VS compiler warning are suppressed by the compiler options declared in the CMAKE config file (in CMakeLists.txt). This is fine to compile LEMON itself, but then the users of LEMON must give these options again explicitly for their own projects. Therefore would be better to do it using #pragma directives, e.g. in lemon/bits/windows.h or in lemon/core.h.

Attachments (1)

warning-pragma.patch (1.5 KB) - added by Akos Ladanyi 15 years ago.
da70af8844b9

Download all attachments as: .zip

Change History (7)

comment:1 Changed 15 years ago by Akos Ladanyi

Status: newassigned

comment:2 in reply to:  description Changed 15 years ago by Akos Ladanyi

Replying to alpar:

... Therefore would be better to do it using #pragma directives, e.g. in lemon/bits/windows.h or in lemon/core.h.

If I disable these warnings in a header file like core.h then they will be disabled in all files which include this header, even in the ones which belong to a program which only uses LEMON. The proper way of doing this is in case of a header file, is that you save the warning settings at the beginning of the header, disable the desired warning messages and at the end of the header you restore the warning settings.

For example in case of cplex.h this would look like this:

#ifndef LEMON_CPLEX_H
#define LEMON_CPLEX_H

#include <lemon/lp_base.h>

#pragma warning( push )
#pragma warning( disable : 4250 )

struct cpxenv;
struct cpxlp;

namespace lemon {
  class CplexEnv { /* ... */ };
  // ...
} //END OF NAMESPACE LEMON

#pragma warning( pop )

#endif //LEMON_CPLEX_H

Of course the #pragmas need to be surrounded by #ifdef _MSC_VER - #endif pairs.

For more information please see: http://msdn.microsoft.com/en-us/library/2c8f766e(VS.71).aspx

comment:3 Changed 15 years ago by Alpar Juttner

I don't think we should go that far. Firstly, the suppressed warning messages complains about programming techniques that are very common when using LEMON, therefore LEMON users will also encounter it from time to time. Secondly, I doubt if this temporarily switched off warnings work well with templates, which are typically instantiated outside of the header file.

IMHO, simply switching these warnings is alright. If someone seriously complains about it, we might reconsider the decision later.

comment:4 in reply to:  3 Changed 15 years ago by Alpar Juttner

Replying to alpar:

IMHO, simply switching these warnings is alright.

I mean, "simply switching _off_ ..."

Changed 15 years ago by Akos Ladanyi

Attachment: warning-pragma.patch added

comment:5 Changed 15 years ago by Akos Ladanyi

Attached a patch.

comment:6 in reply to:  5 Changed 15 years ago by Alpar Juttner

Resolution: done
Status: assignedclosed

Replying to ladanyi:

Attached a patch.

[da70af8844b9] is in both the main and the 1.1 branch now.

Note: See TracTickets for help on using tickets.