2012-03-05 113 views
6

我正在使用C++的ATL COM dll,當我嘗試使用庫時,我得到了許多與最小/最大值有關的錯誤,如此。這似乎也導致了一些其他的錯誤,但我想它們與此有關。警告C4003:宏'min'沒有足夠的實際參數

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代碼中處理。我還可以做些什麼?

回答

8

也許你在直接包含「windows.h」之前放置了#define NOMINMAX,但在包含它的其他頭文件之前沒有?嘗試在源文件的同一開始處移動它(如果沒有)。

+0

我剛試過這個。唯一包含window.h的地方是在一個自動生成的頭文件中,因此所有的改變都被刪除了。在導入這個自動創建的頭文件之前,我在我的類頭文件中添加了#define NOMINMAX,並且該特定錯誤消失了。現在我剩下的問題是內存不足,並要求我在命令行上使用/ Zm選項。但那是我需要解決的一個單獨問題。 – Travis 2012-03-05 07:04:13

相關問題