delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/09/27/10:07:00

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
From: Andy Moreton <andy DOT moreton AT artimi DOT com>
Subject: RE: Strange behaviour with g++ 3.4.4-1
Date: Tue, 27 Sep 2005 13:58:16 +0000 (UTC)
Lines: 41
Message-ID: <Xns96DE984C3CBC5ajmrtmi@80.91.229.5>
References: <Pine DOT OSF DOT 4 DOT 21 DOT 0509262334460 DOT 24737-100000 AT ax0rm1 DOT roma1 DOT infn DOT it>
User-Agent: Xnews/06.08.25
X-IsSubscribed: yes

On Mon, 26 Sep 2005 21:41:29 GMT, Angelo Graziosi wrote:

> 
> 
> Dave Korn wrote:
> 
> 
>> You can fix it like this:
>>
>> dk AT mace /test/cplus> g++ test.fixed.cpp -o test
>> dk AT mace /test/cplus> diff -pu test.cpp test.fixed.cpp
>> --- test.cpp    2005-09-26 10:52:37.405042000 +0100
>> +++ test.fixed.cpp      2005-09-26 10:52:26.555119000 +0100
>> @@ -1,6 +1,8 @@
>> 
>>  #include <iostream>
>>  #include <windows.h>
>> +#undef max
>> +#undef min
>>  #include <complex>
> 
> 
> Thanks, Dave, for the patch.
> 
> I would know if there is some bug somewhere: it sounds strange that moving
> the header 'windows.h' at the beginning or at the end of includes
> sequence, the build works fine.

The problem is that "windows.h" includes "windef.h" which defines the 
standard macros min() and max() without checking if they are already 
defined. You can prevent this behaviour by doing:

//....
#define NOMINMAX
#include "windows.h"
//....

This will prevent the macros from being (illegally) defined twice with 
differing contents.

    	AndyM


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019