mkdir的隐式声明

时间:2013-10-20 16:20:07

标签: c function makefile

对于我的问题,让我假设我有两个函数,它们都是在库文件夹中的.h文件中的原型,以及.c辅助文件中的实现(如下所示),我将使用它们在我的程序中。

calsis.c

 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <fcntl.h>
 #include "include/calsis.h" /* Extern header */ 

char folder_name[30] = "Information";

void no_args() /* Function 1 */
{
  printf("Hello, world!\n");

   if ( mkdir(folder_name, S_IRWXU) == -1 )
    perror("Can't create a new folder");
}

void with_args(char *foo) /* Function 2 */
{
   printf("Hello, world!\n");
   printf("Name: %s\n", foo);

   if ( mkdir(folder_name, S_IRWXU) == -1 )
    perror("Can't create a new folder");
}

对于稍后我将要做的事情,我需要在两个函数中创建一个包含mkdir的文件夹,但是,在生成目标文件 calsis.o 时,通过编译.c文件实现的函数,与GCC的编译给我一个警告, mkdir函数是隐含声明的

我知道我可以删除此警告吗?

1 个答案:

答案 0 :(得分:6)

您尚未加入mkdir的标题:

来自男人(2)mkdir:

SYNOPSIS
       #include <sys/stat.h>
       #include <sys/types.h>

       int mkdir(const char *pathname, mode_t mode);