头文件和makefile的总结

Makefiel文件:包括工程的编译,连接规则,为程序员提供了自动化的编译功能

//vi makefile

 

CC=gcc

CFLAGS=-g -Wall

LDFLAGG=

src=$(wildcard *.c)

target=$(basename $(src))

all:$(target)

 

.PHONY:clean all

clean:

               rm  -rf  *.o $(tsrget)

 

头文件:把运行程序是需要的头问价总结在一起,可以避免代码的重复写,直接调用 “head.h”,封装起来,使程序更规范化,清晰化

头文件  //vi head.h

#ifndef _HEAD_H_
#define _HEAD_H_

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <malloc.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <dirent.h>
#include <assert.h>
#include <sys/wait.h>


#define HEAD_DEBUG


#define  error   do\
          {\
            fprintf(stderr,"[%s]:[%d]:%s\n",__func__,__LINE__,strerror(errno));\
            return -1;\
          }while(0)


#ifdef HEAD_DEBUG
#define debug(f,a...)   do\
             {\
               printf("[%s]:[%d] ",__func__,__LINE__);\
               printf(f,##a);\
             }while(0)
#else
#define debug(f,a...)
#endif        


#define DIR_TRUE  1
#define DIR_FALSE 0


#endif

 

上述两个文件,一个makefile 和 head.h 可以在每次写程序的时候,直接调用。方便化!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值