/*******************************************************************************
* File: a.h
* Description:
* Author: Xiaoyong Wen <wen_kernel@163.com>, 20120523, PM.
*
* Fix hisoty:
*
*******************************************************************************/
#ifndef _A_H
int func_a(void);
#endif /* _A_H */
/*******************************************************************************
* File: a.c
* Description:
* Author: Xiaoyong Wen <wen_kernel@163.com>, 20120523, PM.
*
* Fix hisoty:
*
*******************************************************************************/
#include <stdio.h>
#include "a.h"
int func_a(void)
{
printf("call %s\n", __FUNCTION__);
return 0;
}
static void test1(void)
{
printf("call %s\n", __FUNCTION__);
}
/*******************************************************************************
* File: b.h
* Description:
* Author: Xiaoyong Wen <wen_kernel@163.com>, 20120523, PM.
*
* Fix hisoty:
*
*******************************************************************************/
#ifndef _B_H
int func_b(void);
#endif /* _B_H */
/*******************************************************************************
* File: b.c
* Description:
* Author: Xiaoyong Wen <wen_kernel@163.com>, 20120523, PM.
*
* Fix hisoty:
*
*******************************************************************************/
#include <stdio.h>
#include "b.h"
int func_b(void)
{
printf("call %s\n", __FUNCTION__);
return 0;
}
/*******************************************************************************
* File: main.c
* Description:
* Author: Xiaoyong Wen <wen_kernel@163.com>, 20120523, PM.
*
* Fix hisoty:
*
*******************************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "a.h"
#include "b.h"
int main(int argc, char *argv[])
{
int n;
printf("Run ...\n");
#if 1
func_a();
func_b();
#endif
printf("Exit\n");
return 0;
}
################################################################################
# File: Makefile
# Description:
# Author: Xiaoyong Wen <wen_kernel@163.com>, 20120523, PM.
#
# Fix hisoty:
#
################################################################################
debug := 1
ifdef debug
CFLAGS += -g
else
CFLAGS += -O2
endif
CC := gcc
CFLAGS += -I.
LDFLAGS += -L.
bin := main
obj := main.o a.o b.o
#src := a.c b.c main.c a.h b.h
src := $(wildcard *.c) $(wildcard *.h)
.PHONY : clean all debug
all : $(bin)
@-ls -l $(bin)
$(bin) : $(obj)
$(obj) : $(src)
debug:
@echo $(src)
@echo $(obj)
@echo $(CFLAGS)
@echo $(LDFLAGS)
clean:
rm -f $(bin) $(obj)
本文展示了C语言中文件结构的使用,包括头文件、源文件、函数定义及调用过程,并通过一个简单的主函数示例进行演示。
721

被折叠的 条评论
为什么被折叠?



