多文件编程的小例子
功能:在main.c里面调用其他两个源文件里面的函数,然后输出字符串。

1、main.c    
#include"mytool1.h"
#include"mytool2.h"
int main(int argc,char* argv[])
{
           mytool1_printf("hello.");
           mytool2_print("hello");
           return 1;
}

2、 mytool1.h     mytool1.c
//mytool1.h
#ifndef _MYTOOL_1_H
#define _MYTOOL_1_H
void mytool1_printf(char* print_str);
#endif
 
//mytool1.c
#include"mytool1.h"
#include<stdio.h>
void mytool1_printf(char* print_str)
{
         printf("This is mytool1 print %s\n",print_str);
}

3、 mytool2.h mytool2.c    
//mytool2.h
#ifndef _MYTOOL_2_H
#define _MYTOOL_2_h
void mytool2_print(char* print_str);
#endif
 
//mytool2.c
#include "mytool2.h"<br><br>#include<stdio.h>
void mytool2_print(char* print_str)
{
     printf("This is mytool2 print %s\n",print_str);  
}

makefile:

  1. cc=gcc
  2. target=main
  3. obj=main.o mytool1.o mytool2.o
  4. $(target):$(obj)
  5. $(cc) $(obj) -o $(target)
  6. main.o:main.c
  7. $(cc) -c main.c
  8. mytool1.o:mytool1.c
  9. $(cc) -c mytool1.c
  10. mytool2.o:mytool2.c
  11. $(cc) -c mytool2.c
  12. clean : $(RM) *.o $(target)

注:Makefile有三个非常有用的变量。分别是$@,$^,$<代表的意义分别是:

$@--目标文件,$^--所有的依赖文件,$<--第一个依赖文件。

makefile基本语法的更多相关文章

  1. makefile的语法及写法(二)

     3 Makefile书写规则 -------------------------------------------------------------------------------- 规则包 ...

  2. makefile的语法及写法

    什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了这个工作,但我觉得要作一个好的和professional的程序员,makefile还是要 ...

  3. Makefile基础语法

    Makefile的作用 如果没有Makefile,每次修改源代码后,如果要重新编译代码,都要输入编译命令,当源代码很多时,效率很底下. 基本格式 target: componsnts TAB rule ...

  4. Makefile 基础语法

    1.. specify the directores , i not specified , search current directory put every folder into a list ...

  5. Makefile

    原文链接:http://www.orlion.ga/816/ 一.基本规则 对于一个拥有多个文件的c项目,编译时可能是这样的指令: gcc main.c stack.c -o main 如果编译之后又 ...

  6. C C++ 语法

    非常酷的网站: http://yige.org/cpp/defined_data_types.php 在Linux下有一个目录/proc/$(pid),这个目录保存了进程号为pid的进程运行时的所有信 ...

  7. C++学习笔记25:makefile文件2

    Makefile文件语法 行解析:命令按行解析 命令行的行首字符为Tab键,其他行的行首字符不得为Tab键,但可以使用多个空格缩进 换行:命令太长时,行尾使用"\"换行 注释:行首 ...

  8. 转载-------makefile 使用总结

    转载自:http://www.cnblogs.com/wang_yb/p/3990952.html 1. Makefile 简介 Makefile 是和 make 命令一起配合使用的. 很多大型项目的 ...

  9. (二)我的Makefile学习冲动&&编译过程概述

    前言 一 年轻的冲动 二 学习曲线 1 Makefile基本语法 2 bash基础 3 world 三 编译过程概述 1 主机预装工具 2 编译host工具 3 编译交叉工具链 4 编译内核模块 5 ...

随机推荐

  1. mysql索引学习----2----创建索引、修改索引、删除索引的命令语句

    查看表中已经存在 index:show index from table_name; 创建和删除索引索引的创建可以在CREATE TABLE语句中进行,也可以单独用CREATE INDEX或ALTER ...

  2. linux shell 中数组使用方法介绍

    linux shell在编程方面比windows 批处理强大太多,不管是在循环.运算.已经数据类型方面都是不能比較的. 以下是个人在使用时候,对它在数组方面一些操作进行的总结. 1.数组定义 [che ...

  3. Data Structure Graph: prim

    最小生成树算法.这里的s是可以随意选取的,不影响树的生成,但是不同的s有不同的dis #include <iostream> #include <vector> #includ ...

  4. Ubuntu下,grep的用法

    grep(Global search Regular Expression and Print out the line)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来.U ...

  5. eclipse中集成velocity插件

    1.打开eclipse,点击help,选择install new software 2.点击add,输入下载地址: http://download.eclipse.org/eclipse/update ...

  6. Spark- Spark基本工作原理

    Spark特点: 1.分布式 spark读取数据时是把数据分布式存储到各个节点内存中 2.主要基于内存(少数情况基于磁盘,如shuffle阶段) 所有计算操作,都是针对多个节点上内存的数据,进行并行操 ...

  7. 图数据库Neo4j简介

    图数据库Neo4j简介 转自: 图形数据库Neo4J简介 - loveis715 - 博客园https://www.cnblogs.com/loveis715/p/5277051.html 最近我在用 ...

  8. 单机版 JedisUtil({基本操作封装工具类})【二】

    <!--集成的RedisJAR--> <!--引入jedis需的jar包--> <dependency> <groupId>redis.clients& ...

  9. 素数环:NYOJ--488--dfs||hdu-1016-Prime Ring Problem

    /* Name: NYOJ--488--素数环 Author: shen_渊 Date: 15/04/17 15:30 Description: DFS,素数打个表,37以内就够用了 */ #incl ...

  10. zepto不支持animate({scrollTop:"100px"})的解决办法

    在移动web项目的开发中,遇到一个通过点击页面自动到相应的楼层处的需求,最初的想法就是使用html的target属性进行切换,但实际效果十分死板,显得毫无交互性.该前端架构采用zepto这个轻库进行开 ...