我对 C 还很陌生,但试图通过一个小型 MIDI 音频单元(在 Xcode 4.3.3 中)来更好地理解它。我一整天都在寻找这个问题的答案,但仍然不明白到底问题是什么。这是有问题的代码:
//MyMIDINotifyProc.h
#ifndef MIDIInstrumentUnit_CallbackProcs_h
#define MIDIInstrumentUnit_CallbackProcs_h
void MyMIDINotifyProc (const MIDINotification *message, void *refCon);
#endif
//MyMIDINotifyProc.c
#include <CoreMIDI/CoreMIDI.h>
#include "MyMIDINotifyProc.h"
void MyMIDINotifyProc (const MIDINotification *message, void *refCon) {
//manage notification
}
在 header 定义中我得到这个:
! Cannot combine with previous 'struct' declaration specifier
我已经确保定义匹配并尝试重命名它们,但我仍然在我的 .c 文件中得到这个:
! Redefinition of 'MyMIDINotifyProc' as different kind of symbol
这指向 .h 定义作为“先前的定义”。
我知道CoreMIDI框架中的MIDIServices.h定义了:
typedef void
(*MIDINotifyProc)(const MIDINotification *message, void *refCon);
但我不明白这是否/为什么会导致错误。如果有人能提供帮助,我将不胜感激。
最佳答案
您忘记包含 <CoreMIDI/CoreMIDI.h>
在你的MyMIDINotifyProc.h
头文件。
关于C 错误 - 无法与先前的 'struct' 声明说明符结合 && 将 'MyMIDINotifyProc' 重新定义为不同类型的符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13889335/