ralphjzhang / ell

Automatically exported from code.google.com/p/ell
GNU Lesser General Public License v3.0
0 stars 0 forks source link

usage of 'min' conflicts with windows.h macro #18

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When compiling under Visual Studio (tested 2010 but probably other versions 
too) if the user's C code includes <windows.h> before including ell header 
files, then the macros max(a,b) and min(a,b), which are defined by windows.h, 
cause an internal conflict in ell's code: The constructor of struct DRp at 
UnaryNodes.h (line 164 in current version) contains the assignments min(min), 
max(max) but the compiler misunderstands this as an invocation of the macro. 
This results in the following warnings:

ell/UnaryNodes.h(164): warning C4003: not enough actual parameters for macro 
'min'
ell/UnaryNodes.h(165): warning C4003: not enough actual parameters for macro 
'max'

It is also likely that the resulting code is not compiling correctly, i.e. the 
assignment is not happening.

I have not investigated this more deeply as I am not personally a user of this 
lib, but I am porting a larger lib (that uses ell) to Windows and have run into 
this error.

My workaround at this point is to add #define NOMINMAX before the #include 
<windows.h> , which prevents definition of these macros.

I suggest as a solution not to use the very generic names 'min' and 'max' but 
something else, more specific. Thanks.

Original issue reported on code.google.com by ita...@gmail.com on 29 Aug 2013 at 11:34

GoogleCodeExporter commented 9 years ago
#define NOMINMAX before including windows.h

VBR

Jerry

Original comment by jerrymev...@gmail.com on 18 Sep 2013 at 9:04