【问题标题】:warning C4003: not enough actual parameters for macro 'min'警告 C4003:宏“min”的实际参数不足
【发布时间】:2012-03-22 16:07:03
【问题描述】:

我正在使用 C++ 编写 ATL COM dll,当我尝试使用库时,我遇到了一些与 min/max 相关的错误,例如这个。尽管我认为它们与此有关,但它似乎也导致了许多其他错误。

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 : '('

这个头文件中的内联宏定义为:

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

无论如何,我在这里阅读了许多讨论这个问题并表明我可以使用的帖子

#define NOMINMAX before #include "windows.h"

但是这不起作用,我仍然得到错误。我不想修改库,因为它很大,我不想让我的项目依赖于自定义库,所以我更喜欢我可以在我的 dll 代码中处理的某种解决方案。我还能做什么?

【问题讨论】:

    标签: c++ header inline atl


    【解决方案1】:

    也许您在直接包含“windows.h”之前放置了#define NOMINMAX,而不是在包含它的其他标题之前?尝试将它移动到源文件的同一开头(如果没有)。

    【讨论】:

    • 我刚试过这个。唯一包含 window.h 的地方是在自动生成的头文件中,因此那里的任何更改都会被删除。在导入这个自动创建的头文件之前,我在我的类头文件中添加了#define NOMINMAX,并且那个特定的错误消失了。现在我遇到了一个内存不足的问题,并要求我在命令行上使用 /Zm 选项。但这是我需要解决的另一个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 2010-12-26
    • 1970-01-01
    相关资源
    最近更新 更多