我不明白这是什么意思:错误:返回类型是一个不完全类型
error: return type is an incomplete type"
我只是想返回结构。我分开了两个音频通道,我想使用唯一的函数使用结构返回它们。
的main.c:
#include "functions.h"
...
struct LandR sepChannels_8(unsigned char *, unsigned long, unsigned char *, unsigned char *);
...
int main()
{
...
sepChannels_8(ptrSamples_8, n, ptrSamples_8_L, ptrSamples_8_R);
...
}
function.h:
...
struct LandR sepChannels_8(unsigned char *smp, unsigned long N, unsigned char *L, unsigned char *R)
{
struct LandR
{
unsigned char *L;
unsigned char *R;
};
struct LandR LRChannels;
int i;
if (N % 2 == 0)
{
L = malloc(N/2);
R = malloc(N/2);
}
else
if (N % 2 == 1)
{
L = malloc(N/2);
R = malloc(N/2);
}
for (i = 0; i < N; i++) // separating
{
L[2 * i + 0] = smp[2 * i + 0];
R[2 * i + 0] = smp[2 * i + 1];
}
return LRChannels;
}
...
结构_defined_在你尝试使用它的地步吗?这是你的示例代码中的拼写错误,还是你真的想在函数本身中定义函数的返回类型? –
您对'.c'和'.h'文件的使用非常倒退 - 您在'main.c'中创建了原型,在'function.h'中创建了函数体。但是你确实设法把'main'放在'main.c'中。 –