c - invalid initializer in a struct pointer function
问题描述
I want to pass a struct as parameter in a function. But it's failed when i compile it. Here is my struct definition. It's defined in svm.h and declaration in svm.cpp
#ifdef __cplusplus
extern "C" {
#endif
struct svm_model
{
struct svm_parameter param; /* parameter */
int nr_class; /* number of classes, = 2 in regression/one class
svm */
int l; /* total #SV */
struct svm_node **SV; /* SVs (SV[l]) */
double **sv_coef; /* coefficients for SVs in decision functions
(sv_coef[k-1][l]) */
double *rho; /* constants in decision functions (rho[k*(k-1)/2])
*/
double *probA; /* pariwise probability information */
double *probB;
int *sv_indices; /* sv_indices[0,...,nSV-1] are values in
[1,...,num_traning_data] to indicate SVs in the training set */
/* for classification only */
int *label; /* label of each class (label[k]) */
int *nSV; /* number of SVs for each class (nSV[k]) */
/* nSV[0] + nSV[1] + ... + nSV[k-1] = l */
/* XXX */
int free_sv; /* 1 if svm_model is created by svm_load_model*/
/* 0 if svm_model is created by svm_train */
};
....
#ifdef __cplusplus
}
#endif
And here is my function definition. It is declared in syll_fragmentation.h and defined in syll_fragmentation.c Declaration:
void real_time_predict(struct svm_model *model, SAMPLE *sum_normal);
Definition:
void real_time_predict(struct svm_model *model, SAMPLE *sum_normal) {}
In main function, i call this function :
struct svm_model *model;
if ((model = svm_load_model(model_path)) == 0) {
fprintf(stderr, "cant load model file \n");
exit(1);
}
SAMPLE *sum_normal = (SAMPLE*)malloc(sizeof(SAMPLE) * 91);
mfcc_load_normalized_sum(sum_normal, sum_path);
real_time_predict(model, sum_normal);
The error i got is invalid initializer, which reference with real_time_predict function. I'm using gcc to compile. And here is error log:
syll_fragmentation.c:217:13: error: invalid initializer
line 217 is declaration of real_time_predict function.I don't know why, please help me, thank you guys!!!
解决方案
推荐阅读
- angular - Ng build with chunking without the --watch flag 与 nodemon 和 electron 结合使用
- sap-cloud-platform - SAP BTP CF Apps APIs 上的 DOS 攻击缓解/速率限制
- python - 如何使用滚动功能来预测基于简单移动平均线或其他策略的趋势
- visual-c++ - KLR 2 Baru.exe 中 0x00007FF610DE1904 处的未处理异常:0xC0000005:访问冲突读取位置 0x000000BE306C4F20
- node.js - 使用单独集合中的特定文档的引用创建新文档后,如何更新集合中的文档?
- android - 在 docker 容器中运行 Android 模拟器
- windows - 批处理 - 获取标志之间的文本块,输出并遍历所有文件
- c++ - 如何在内存中创建一个虚拟文件并将其用作普通的 FILE 指针?
- c# - 使用通用接口从组合接口模型转换模型?
- laravel - 如何在 Laravel 8 中预览 pdf 文件?