当我尝试编译以下代码时,出现错误:
“ include / IBCppClient / client / SoftDollarTier.h | 3 |错误:变量 “ TWSAPIDLLEXP SoftDollarTier”具有初始化程序,但类型不完整|”。
我猜代码是正确的,因为它是股票经纪人API的一部分。但是,我很难理解类定义"class TWSAPIDLLEXP SoftDollarTier"
的内容。据我所知,这种语法在C ++中是不合法的。我想念什么?
class TWSAPIDLLEXP SoftDollarTier{
std::string m_name, m_val, m_displayName;
public:
SoftDollarTier(const std::string& name = "", const std::string& val = "", const std::string& displayName = "");
std::string name() const;
std::string val() const;
std::string displayName() const;
};
答案 0 :(得分:0)
C ++允许使用宏定义,这些定义使C预处理程序可以使用更详尽的定义来本质上查找和替换这些宏。 C / C ++中的一种常见做法是使用预处理器宏在函数名称之前插入函数属性,并且可能发生的情况是您的环境不包含定义$('#theForm').on('submit',function(e){
e.preventDefault();
let formData = new FormData();
formData.append('fname',$('#theForm input[name=first_name]').val());
//... appending lots of data + file
$.ajax({
contentType: false,
processData: false,
cache: false,
type: 'POST',
dataType: 'json',
url: '/lib/ajax.php',
data: formData,
success: function (data) {
//celebrate
},
error: function (XMLHttpRequest, textStatus, errorThrown){
$('.submit-result').html(textStatus);
},
timeout: 5000
});
});
的头文件,因此编译器将字符串解释为类名称。
通过快速搜索,似乎tws-api中定义了TWSAPIDLLEXP
(不确定这是否是相同的代理):
TWSAPIDLLEXP
在#define TWSAPIDLLEXP __declspec(dllimport)
中。