c - 警告 : Implicit declaration error

标签 c include warnings

<分区>

这是文件,我想使用包括: 原语.h:

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

基元.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;
}

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

最佳答案

编译器并没有说函数没有定义。它说该函数在文件 primitives.c 中使用之前没有声明,那里有它的调用

setTitreMeta(Nouv_Bloc.infosFic,nomfic);

所以编译器无法判断这个调用是否有效。

关于c - 警告 : Implicit declaration error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30692183/

相关文章:

php - 将文件包含在 PHP 中后无法定位文件

android - 如何在 Eclipse 中的 Android 项目中的代码旁边显示警告?

node.js - 如何查找 Node.js UnhandledPromiseRejectionWarning 中哪些 Promise 未处理?

c - OS X 内存集和系统跟踪

C:执行手动映射的文本段,无需编写太多程序集

c - Lua注册的C函数调用另一个

android - 嵌套的preferences.xml

C : Veryfing that a parameter is an int parameter

PHP: 'include' , 但不要运行

php - 错误 : Warning: Creating default object from empty value