gpt4 book ai didi

c++ - 使用外部变量导致 "unsigned char"错误 LNK2001

转载 作者:行者123 更新时间:2023-11-28 04:41:07 27 4
gpt4 key购买 nike

<分区>

我在头文件中定义了两个 extern unsigned char,用于在两个类之间传输两个 char。在第一个 .cpp 中,我像普通变量一样使用它们来存储我从函数获得的输入,而无需任何进一步声明,如下所示:

测试.h

extern unsigned char tempName;
extern unsigned char tempValue;

测试.cpp

void NanoKontrol2::midi_in_proc(UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2) {
unsigned char ch_msg, data1, data2, data3;

switch (wMsg) {
case MIM_DATA:
ch_msg = (unsigned char)(0xFF & dwParam1);
data1 = (unsigned char)(0xFF & (dwParam1 >> 8));
data2 = (unsigned char)(0xFF & (dwParam1 >> 16));
data3 = (unsigned char)(0xFF & (dwParam1 >> 24));
/*on_message(ch_msg, data1, data2, data3);*/
tempName = data1;
tempValue = data2;
/*on_change_value(tempName, tempValue);*/
break;
default:
break;
}
}

现在我需要第二类 needhere.cppmidi_in_proctempVariables 中存储的值。

我试着在 needhere.cpp 类中使用它们,如下所示:

if (NK2_FADER_0 <= tempName && tempName <= NK2_FADER_7) {
fader1 = tempValue;
}
//Knobs
else if (NK2_ROTARY_KNOB_0 <= tempName && tempName <= NK2_ROTARY_KNOB_7) {
knob1 = tempValue;
}

Visual Studio 没有显示任何错误。但是当我尝试编译时,我得到了这 6 个错误:

Severity    Code    Description Project File    Line    Suppression State
Error LNK1120 3 unresolved externals MayaNK2Node C:\Users 1
Error LNK2001 unresolved external symbol "public: static class NanoKontrol2 MayaNK2Node::nanoKONTROL2" (?nanoKONTROL2@MayaNK2Node@@2VNanoKontrol2@@A 1
Error LNK2001 unresolved external symbol "unsigned char tempName" (?tempName@@3EA)
Error LNK2001 unresolved external symbol "unsigned char tempName" (?tempName@@3EA)
Error LNK2001 unresolved external symbol "unsigned char tempValue" (?tempValue@@3EA)
Error LNK2001 unresolved external symbol "unsigned char tempValue" (?tempValue@@3EA)

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com