Opened 16 years ago
Closed 16 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)
Change History (7)
comment:1 Changed 16 years ago by
| Status: | new → assigned | 
|---|
comment:2 Changed 16 years ago by
comment:3 follow-up: 4 Changed 16 years ago by
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 Changed 16 years ago by
Replying to alpar:
IMHO, simply switching these warnings is alright.
I mean, "simply switching _off_ ..."
comment:6 Changed 16 years ago by
| Resolution: | → done | 
|---|---|
| Status: | assigned → closed | 


Replying to alpar:
If I disable these warnings in a header file like
core.hthen 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.hthis 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_HOf course the
#pragmas need to be surrounded by#ifdef _MSC_VER-#endifpairs.For more information please see: http://msdn.microsoft.com/en-us/library/2c8f766e(VS.71).aspx