我有2个.c文件,我将尝试调用read_cfg(struct)来分配结构中的数据,但我收到错误的“冲突类型” .h文件中冲突的类型为read_cfg()
example.c
#include<stdio.h>
#include"example.h"
struct config /structure
{
char data[10];
};
int main()
{
int n=0;
struct data d;
read_cfg(&d); //function call
}
example.h文件
#ifndef EXAMPLE_H
#define EXAMPLE_H
extern void read_cfg(struct); //ERROR
examplelib.c
struct config //structure
{
char data[10];
};
void read_cfg(struct config_data *cfg) //function implementation
{
struct config_data tmp;
strcpy(tmp.data,"helo");
cfg=&tmp;
}
任何帮助将是我
感谢
请检查您的问题中的代码:您有3种不同的结构类型:'struct config','struct data'和'struct config_data'。这些应该是同一类型吗?请阅读[mcve]。 – user694733