yul*_*ian 5 c struct return-type
我不明白这是什么意思:
error: return type is an incomplete type"
Run Code Online (Sandbox Code Playgroud)
我只想返回结构。我已经分离了两个音频通道,我想使用 only 函数使用结构返回它们。
主文件:
#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 );
...
}
Run Code Online (Sandbox Code Playgroud)
函数.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;
}
...
Run Code Online (Sandbox Code Playgroud)
如果你想使用一个类型,你需要先声明它。
struct LandR在本地声明为sepChannels_8.
如果要将声明作为函数的返回类型公开,请将声明移动到全局范围内。
另外:根据约定原型和常量以及类型定义进入.h文件。实现进入.c文件。