[Insight-users] please ignore above question about "macro max requires 2 arguemnts ..."

Di Xiao xiaodimailing at hotmail.com
Mon Mar 21 08:44:29 EST 2005


Dear Mr. Luis:

  Thanks for your reply. Yes, I also read the email you ever replied to 
Chad, very similar like mine.
However, I use Redhat linux 8.0 rather windows. So, I am a little confused 
by this problem.

Regards,

Xiao Di




Dear All:

   My project is runing in Redhat 8.0, gcc-3.2-7.
The problem I met is once I included  "itkPointSet.h" in the project, it
will give error as:

In file included from
/usr/local/include/InsightToolkit/Common/itkPointSet.h:26,
from mainwin.ui.h:88,
from mainwin.cpp:23:
/usr/local/include/InsightToolkit/Common/itkPointLocator.h:96:71: macro
"max" requires 2 arguments, but only 1 given

I find the same problem ever talked in the mailing list as attached.
But I didnt use any "max" variable in my program. And I checked
"undef min" and "undef max" is defined in itkNumericTraits.h.

Can anyone give suggestion how to solve it?

Thanks

Xiao Di



Attached:  Disscussed topic

HI Chad,

Please follow Paul's advice. He is right.
min and max are defined in windows standard
headers (for example).  ITK undefine them
in itkNumbericTraits.h in Insight/Code/Common.

Strange that this undef is not working for you,
it should make this platform independent.

We probably don't have a dashboard with gcc 3.2.3....


Regards,


   Luis


----------------------
Paul Yushkevich wrote:
>Chad,
>
>I'm not sure that my answer is right, but try doing this: change the names 
>of the variables min and max to myMin and myMax.  In some compilers min and 
>max are #defined macros and that may be causing the problem.  I know that 
>I've had no problem using the MinMaxCalculator with the gcc compiler.
>
>On the other note, I would recommend using myCalculator->Compute() instead 
>of ComputeMin and ComputeMax.  It should be a little more efficient when 
>you need both the min and the max.
>
>Paul
>
>Chad Washington wrote:
>
>>I am trying to use the Min/Max calculator and keep getting errors when I 
>>compile the code.  I am using gcc 3.2.3 and have the following 
>>definitions:
>>
>>typedef int     PixelType;
>>typedef itk::Image< PixelType, 2 >     ImageType;
>>typedef itk::MinimumMaximumCalculator< ImageType >     CalculatorType;
>>
>>and the code:
>>ImageType::PixelType min;
>>ImageType::PixelType max;
>>myCalculator->SetImage( myImage );
>>myCalculator->ComputeMinimum();
>>min = myCalculator->GetMinium();
>>myCalculator->ComputMaximum();
>>max = myCalculator->GetMaximum();
>>
>>The resulting errors:
>>In file included from                 from 
>>itkMinimumMaximumImageCalculator.h:110,
>>                 from mie.h:28,
>>                 from mie.cxx:57:
>>Insight/Code/BasicFilters/itkMinimumMaximumImageCalculator.txx:47:45: 
>>macro "min" requires 2 arguments, but only 1 given
>>Insight/Code/BasicFilters/itkMinimumMaximumImageCalculator.txx:48:45: 
>>macro "max" requires 2 arguments, but only 1 given
>>Insight/Code/BasicFilters/itkMinimumMaximumImageCalculator.txx:78:45: 
>>macro "max" requires 2 arguments, but only 1 given
>>Insight/Code/BasicFilters/itkMinimumMaximumImageCalculator.txx:102:45: 
>>macro "min" requires 2 arguments, but only 1 given
>>Insight/Code/BasicFilters/itkMinimumMaximumImageCalculator.txx: In
>>   member function `void
>>   itk::MinimumMaximumImageCalculator<TInputImage>::ComputeMaximum() [with
>>   TInputImage = ImageType]':
>>mie.cxx:1653:   instantiated from here
>>Insight/Code/BasicFilters/itkMinimumMaximumImageCalculator.txx:102: 
>>invalid
>>   conversion from `int (*)()' to `int'
>>Insight/Code/BasicFilters/itkMinimumMaximumImageCalculator.txx: In
>>   member function `void
>>   itk::MinimumMaximumImageCalculator<TInputImage>::ComputeMinimum() [with
>>   TInputImage = ImageType]':
>>mie.cxx:1674:   instantiated from here
>>Insight/Code/BasicFilters/itkMinimumMaximumImageCalculator.txx:78: invalid
>>   conversion from `int (*)()' to `int'
>>
>>Thanks,
>>Chad Washington
>>Biomedical Modeling Laboratory
>>Department of Biomedical Engineering
>>Vanderbilt University

_________________________________________________________________
Get an advanced look at the new version of MSN Messenger.
http://messenger.msn.com.sg/Beta/Default.aspx




>From: Luis Ibanez <luis.ibanez at kitware.com>
>To: Di Xiao <xiaodimailing at hotmail.com>
>CC: insight-users at itk.org
>Subject: Re: [Insight-users] please ignore above question about "macro max 
>requires 2 arguemnts ..."
>Date: Sat, 19 Mar 2005 20:09:05 -0500
>
>
>Hi Xia,
>
>Just for the record,
>
>The error that you were getting is caused because
>VisualStudio defines min() and max() as Macros.
>
>ITK headers "undef" such dangerous macros and make
>possible to differentiate between them and real
>function definitions.
>
>Setting includes for ITK headers at the beginning
>makes that the "undef" appear on time, before the
>min and/or max functions are used.
>
>
>    Regards,
>
>
>       Luis
>
>
>
>-----------------
>Di Xiao wrote:
>
>>
>>Sorry.
>>
>>It seems putting the "itkPointSet.h" above all other headers can solve  
>>"macro max requires two arguments, but only 1 given".
>>
>>xiao di
>>
>>_________________________________________________________________
>
>
>

_________________________________________________________________
Download MSN Messenger emoticons and display pictures. 
http://ilovemessenger.msn.com/?mkt=en-sg



More information about the Insight-users mailing list