可视C++速递:找不到 fmin 和 fmax 标识符
Visual C++ Express: fmin and fmax identifier not found?
我已经在Mac上编译了这段代码,所以我知道没有语法错误,但是,在VC++ Express 2010中,我收到一个错误,说找不到fmin和fmax标识符。我安装了Windows SDK 7.1以查看是否可以修复它,但它什么也没做:/
#include "DigitalDistortion.h"
#include "IPlug_include_in_plug_src.h"
#include "IControl.h"
#include "resource.h"
const int kNumPrograms = 1;
enum EParams
{
kThreshold = 0,
kNumParams
};
enum ELayout
{
kWidth = GUI_WIDTH,
kHeight = GUI_HEIGHT,
kThresholdX = 100,
kThresholdY = 100,
kKnobFrames = 60
};
DigitalDistortion::DigitalDistortion(IPlugInstanceInfo instanceInfo)
: IPLUG_CTOR(kNumParams, kNumPrograms, instanceInfo), mThreshold(1.)
{
TRACE;
//arguments are: name, defaultVal, minVal, maxVal, step, label
GetParam(kThreshold)->InitDouble("Threshold", 100., 0.01, 100.0, 0.01, "%");
GetParam(kThreshold)->SetShape(2.);
IGraphics* pGraphics = MakeGraphics(this, kWidth, kHeight);
pGraphics->AttachPanelBackground(&COLOR_RED);
IBitmap knob = pGraphics->LoadIBitmap(KNOB_ID, KNOB_FN, kKnobFrames);
pGraphics->AttachControl(new IKnobMultiControl(this, kThresholdX, kThresholdY, kThreshold, &knob));
AttachGraphics(pGraphics);
//MakePreset("preset 1", ... );
MakeDefaultPreset((char *) "-", kNumPrograms);
}
DigitalDistortion::~DigitalDistortion() {}
void DigitalDistortion::ProcessDoubleReplacing(
double** inputs,
double** outputs,
int nFrames)
{
// Mutex is already locked for us.
int const channelCount = 2;
for (int i = 0; i < channelCount; i++) {
double* input = inputs[i];
double* output = outputs[i];
for (int s = 0; s < nFrames; ++s, ++input, ++output) {
if(*input >= 0) {
// Make sure positive values can't go above the threshold:
*output = fmin(*input, mThreshold);
} else {
// Make sure negative values can't go below the threshold:
*output = fmax(*input, -mThreshold);
}
*output /= mThreshold;
}
}
}
void DigitalDistortion::Reset()
{
TRACE;
IMutexLock lock(this);
}
void DigitalDistortion::OnParamChange(int paramIdx)
{
IMutexLock lock(this);
switch (paramIdx)
{
case kThreshold:
mThreshold = GetParam(kThreshold)->Value() / 100.;
break;
default:
break;
}
}
fmin
和fmax
是C99功能。Visual Studio只实现了C89标准,所以它没有该功能。
由于它是C++的,你可以(而且,我敢说,应该)使用<algorithm>
标头中的std::min
和std::max
函数。
这些是函数模板,因此它们将接受为其定义了比较运算符的任何类型的模板。只需确保两个参数的类型相同,否则可能无法编译。
相关文章:
- 在C++中,是否可以基于给定的标识符创建基类的新实例,反之亦然
- #ifdef和未声明的标识符
- f2、f3、f4标识符未找到
- 设置 Visual Studio for MPI: 找不到标识符错误
- 未声明的标识符编译暗黑破坏神 2 程序"muleview"
- 在顶点着色器中使用 OpenGl 的未声明标识符,我在顶点着色器中绘制三角形时遇到问题
- Google protobuf 时间戳未声明标识符,在 Windows 上具有C++
- 如何让 GCC/Clang 在保留标识符上出错
- 错误 C2760:语法错误:映射迭代器上意外的标记"标识符",预期的";"
- 当简单捕获中的标识符显示为参数的声明符 ID 时,没有编译器诊断
- 使用说明符 extern 声明的C++中的标识符链接
- C++:枚举:错误:应使用标识符而不是"}"
- 为什么我们不能重复使用具有不同模板参数的别名模板标识符?
- Visual Studio C++ PlaySound 标识符未定义
- 为什么我们不编写可以处理C++标识符的汇编器和链接器?
- 使用未声明的标识符"sqrt"?
- 找不到标识符合并
- 在模板化函数中重新定义(忽略)的 SWIG 标识符
- fmax 和 fmin 需要一个标识符 Visual Studio C++
- 可视C++速递:找不到 fmin 和 fmax 标识符