2012-03-05 22 views
6

Tôi đang làm việc trên một dll ATL COM trong C++ và khi tôi cố gắng sử dụng thư viện, tôi nhận được một số lỗi liên quan đến min/max như thế này. Nó cũng có vẻ gây ra một số lỗi khác mặc dù tôi tưởng tượng họ có liên quan đến điều này.cảnh báo C4003: không đủ thông số thực tế cho macro '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 : '(' 

vĩ mô nội tuyến trong tiêu đề này được định nghĩa là:

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

Dù sao, tôi đã đọc một số bài viết trên đây mà thảo luận về vấn đề này và chỉ ra rằng tôi có thể sử dụng

#define NOMINMAX before #include "windows.h" 

tuy nhiên điều này không hoạt động và tôi vẫn gặp lỗi. Tôi không muốn phải sửa đổi các thư viện vì nó lớn và tôi không muốn có dự án của tôi phụ thuộc vào một thư viện tùy chỉnh vì vậy tôi muốn một số loại giải pháp mà tôi có thể xử lý trong mã dll của tôi. Tôi có thể làm gì nữa?

Trả lời

8

Có thể bạn đã đặt #define NOMINMAX ngay trước khi trực tiếp bao gồm "windows.h" nhưng không phải trước một số tiêu đề khác bao gồm tiêu đề đó? Hãy thử di chuyển nó ở cùng một đầu của tập tin nguồn (nếu bạn không).

+0

Tôi vừa thử điều này. Địa chỉ window.h duy nhất được bao gồm trong tệp tiêu đề được tạo tự động, vì vậy mọi thay đổi đã bị xóa. Tôi đã thêm #define NOMINMAX vào tệp tiêu đề lớp trước khi nhập tệp tiêu đề được tạo tự động này và lỗi cụ thể đó đã biến mất. Bây giờ tôi còn lại với một vấn đề mà nó hết bộ nhớ và yêu cầu tôi sử dụng tùy chọn/Zm trên dòng lệnh. Nhưng đó là một vấn đề riêng biệt tôi cần phải làm việc. – Travis

Các vấn đề liên quan