这里的文件,我想使用包括: primitives.h:警告:隐式声明的错误
#ifndef PRIMITIVES_H_
#define PRIMITIVES_H_
#include "bloc.h"
#endif
primitives.c
#include "primitives.h"
Bloc_T creat2(char* ,BT_T);
Bloc_T creat2(char* nomfic ,BT_T typefic)
{
Bloc_T Nouv_Bloc;
setTitreMeta(Nouv_Bloc.infosFic,nomfic);
Nouv_Bloc.typeBloc= typefic;
return Nouv_Bloc;
}
bloc.h:
#ifndef STRUCTURES_H_INCLUDED
#define STRUCTURES_H_INCLUDED
// BIBLIOTHEQUES STANDARDS
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
// MACROS
#define TAILLE_BD 20
#define NBR_BLOC_PAR_FIC 5
struct Metadonnees
{
char* nomFic;
};
// Alias
typedef struct Metadonnees MD_T;
enum blocType{
BV,BD,BREP,BI
};
//别名 typedef enum blocType BT_T;
struct Bloc
{
BT_T typeBloc;
int** adressesInodes; //tableau des adresses des BD (BI ou BRep)
MD_T infosFic;
char* data; //bloc données
char** nomsFic; // pour les BRep
// bloc vide: tout à null
};
// Alias
typedef struct Bloc Bloc_T;
我得到这样的警告:
primitives.c:8:2: attention : implicit declaration of function ‘setTitreMeta’ [-Wimplicit-function-declaration]
但我已经在bloc.c.定义它
编辑:Bloc.c 的#include “bloc.h”
void setTitreMeta(MD_T , char*);
void setTitreMeta(MD_T meta, char* titre)
{
int taille = strlen(titre);
meta.nomFic=(char*)malloc(sizeof(char)*taille);
strcpy(meta.nomFic,titre);
printf("Nom du fichier: %s\n",meta.nomFic);
}
我定义它bloc.c,但它让我看到警告..我应该把它定义(声明它) ?
好吧,'setTitreMeta'没有在你发布的代码中的任何地方原型化,那么你还期望什么? – szczurcio
这里我添加了bloc.c,但总是警告 – user3568611