【发布时间】:2020-07-23 15:36:14
【问题描述】:
我目前正在用 C++ 编写 VST,但遇到了问题。我已经在网上冲浪和 StackOverflow 有一段时间了,但我被卡住了。两个文件给了我这个问题,SynthesizerTwo.h 和 SynthesizerTwo.cpp。
我得到的错误是:
'kNumPrograms': undeclared identifier [in SynthesizerTwo.h]
我有一个名为 kNumPrograms 的 const int,它在 SynthesizerTwo.cpp 中声明如下:
#include "SynthesizerTwo.h"
#pragma warning( suppress : 4101 4129 )
#include "IPlug_include_in_plug_src.h"
#include "IControl.h"
#include "resource.h"
const int kNumPrograms = 1; //Original Declaration
enum EParams
{
kNumParams
};
然后,在SynthesizerTwo.h 中,在SynthesizerTwo 类中使用如下:
#ifndef __SYNTHESIZERTWO__
#define __SYNTHESIZERTWO__
#include "Oscillator.h"
#include "MIDIReceiver.h"
#pragma warning( suppress : 4101 4129 )
#include "IPlug_include_in_plug_hdr.h"
class SynthesizerTwo : public IPlug
{
public:
SynthesizerTwo(IPlugInstanceInfo instanceInfo);
~SynthesizerTwo();
//const int kNumPrograms = 5;
void Reset();
void OnParamChange(int paramIdx);
void ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames);
// to receive MIDI messages:
void ProcessMidiMsg(IMidiMsg* pMsg);
private:
double mFrequency;
void SynthesizerTwo::CreatePresets() {
MakeDefaultPreset((char*)"-", kNumPrograms); //This is what gives me the error
}
Oscillator mOscillator;
MIDIReceiver mMIDIReceiver;
};
#endif
我尝试将声明放入 .h 文件,但随后出现 LNK2019 链接器错误。我还尝试在 .cpp. 和 .h 的声明之前使用 extern。
我尝试将声明放在类之外的.h、公共部分和私有部分。我还尝试将 .cpp 中的声明移到 .h #include 上方,但仍然出现错误。
链接器错误:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: void __thiscall MIDIReceiver::advance(void)" (?advance@MIDIReceiver@@QAEXXZ) referenced in function "public: virtual void __thiscall SynthesizerTwo::ProcessDoubleReplacing(double * *,double * *,int)" (?ProcessDoubleReplacing@SynthesizerTwo@@UAEXPAPAN0H@Z) SynthesizerTwo-vst2 C:\wdl-ol\IPlugExamples\SynthesizerTwo\SynthesizerTwo.obj 1
任何帮助将不胜感激。
【问题讨论】:
-
void SynthesizerTwo::CreatePresets()应该是void CreatePresets()。将该函数的实现移动到.cpp文件中(在kNumPrograms的声明之后)。 -
无关:你为什么要投射
(char*)"-"而不是只调用MakeDefaultPreset("-", kNumPrograms);? -
谢谢,我试试看。
-
不相关:由于您链接到的框架已存档,并且它们链接到新框架iPlug2,也许您最好从它开始?
-
是的,我决定将框架切换到 iPlug2。感谢您的帮助!
标签: c++ declaration identifier vst