警告:隐式声明错误 [英] warning : Implicit declaration error

查看:428
本文介绍了警告:隐式声明错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我想使用的文件包括:
primitives.h:

Here's the files , i want to use includes : primitives.h:

#ifndef PRIMITIVES_H_
#define PRIMITIVES_H_
#include "bloc.h"
#endif

primitives.c

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;

// Alias 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中定义了它。

But i have defined it in bloc.c.

编辑:Bloc.c
#includebloc .h

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中定义它,但它向我显示警告。我应该在哪里定义它(声明它)?

I'm defining it in bloc.c but it shows me the warning .. where should I define it ( declare it )?

推荐答案


但是我已经在bloc中定义了它.c。

But i have defined it in bloc.c.

您可能已定义,但您还必须声明 it

You may have defined it, but you also have to declare it

bloc.h 中声明所述功能应该修复它。

Declaring said function in bloc.h should fix it.

这篇关于警告:隐式声明错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆