[Insight-users] help about macro "max" requires 2 arguments, but only 1 given

Di Xiao xiaodimailing at hotmail.com
Fri Mar 18 21:56:22 EST 2005


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



More information about the Insight-users mailing list