warning C4003: not enough actual parameters for macro 'min'
Asked Answered
R

1

6

I am working on an ATL COM dll in c++ and when I attempt to make use of a library I get a number of errors related to min/max such as this. It also seems to cause a number of other errors though I imagine they are related to this.

1>stdafx.cpp
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(364) : warning C4003: not enough actual parameters for macro 'min'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(366) : warning C4003: not enough actual parameters for macro 'min'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(372) : warning C4003: not enough actual parameters for macro 'max'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(376) : warning C4003: not enough actual parameters for macro 'max'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(378) : warning C4003: not enough actual parameters for macro 'max'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(364) : error C2059: syntax error : '('
1>        c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(413) : see reference to class template instantiation 'OpenMS::DPosition<D>' being compiled
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(364) : error C2059: syntax error : ')'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(364) : error C2143: syntax error : missing ')' before '?'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(364) : error C2143: syntax error : missing ';' before '?'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(364) : error C2574: 'OpenMS::DPosition<D>::DPosition(void)' : cannot be declared static
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(364) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(376) : error C2059: syntax error : '('
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(376) : error C2059: syntax error : ')'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(376) : error C2143: syntax error : missing ')' before '?'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(376) : error C2143: syntax error : missing ';' before '?'
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(376) : error C2574: 'OpenMS::DPosition<D>::DPosition(void)' : cannot be declared static
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(376) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>c:\dropbox\openms-1.6.0\include\openms\datastructures\dposition.h(364) : error C2059: syntax error : '('

the inline macro in this header is defined as:

    /// smallest positive
    inline static const DPosition
    min()
    {
      return DPosition(std::numeric_limits<typename DPosition::CoordinateType>::min());
    }

Anyway, I have read a number of posts on here that discuss this problem and indicate that I can use

#define NOMINMAX before #include "windows.h"

however this did not work and I still get the errors. I do not want to have to modify the library as it is large and I would rather not have to have my project depend on a customized library so I would prefer some sort of solution that I can handle within my dll code. What else can I do?

Rochet answered 5/3, 2012 at 6:8 Comment(0)
H
8

Maybe you placed #define NOMINMAX right before directly including "windows.h" but not before some other header which include it? Try moving it at the same beginning of the source file (if you didn't).

Haldan answered 5/3, 2012 at 6:58 Comment(1)
I just tried this. The only place window.h is included is within an automatically generated header file, so any changes there got obliterated. I added #define NOMINMAX in my class header file before it imports this automatically created header file and that particular error went away. Now I am left with a problem where it ran out of memory and asked me to use the /Zm option on the command line. But that is a separate problem I need to work out.Rochet

© 2022 - 2024 — McMap. All rights reserved.