zoukankan      html  css  js  c++  java
  • GNU make manual 翻译(二十)

    继续翻译

    2.4 Variables Make Makefiles Simpler                        
    ====================================                        
                            
    In our example, we had to list all the object files twice in the rule                        
    for `edit' (repeated here):                        
                            
         edit : main.o kbd.o command.o display.o \                        
                       insert.o search.o files.o utils.o                        
                 cc -o edit main.o kbd.o command.o display.o \                        
                       insert.o search.o files.o utils.o                        
                            
       Such duplication is error-prone; if a new object file is added to the 
    system, we might add it to one list and forget the other.  We can
    eliminate the risk and simplify the makefile by using a variable. 
    Variables allow a text string to be defined once and substituted in 
    multiple places later (*note How to Use Variables: Using Variables.).  

    2.4 变量使得makefile 更加简单 
    ====================================
    在我们的例子中,我们在 edit 的规则里面,不得不列举了所有目标文件两次:

    edit : main.o kbd.o command.o display.o \
    insert.o search.o files.o utils.o
    cc -o edit main.o kbd.o command.o display.o \
    insert.o search.o files.o utils.o

    这种重复容易导致出错;如果一个新的 目标文件被加入到系统中,我们也许会在某处加入了,而某处忘记了加入。

    我们可以通过使用变量,来消除这个风险,简化makefile。

    变量允许一个文本串定义一次,到处使用(*not How to Use Variables:Using Variables)。

    后文待续

  • 相关阅读:
    wait函数和waitpid的使用和总结
    linux中sleep函数的使用和总结
    alarm()函数的使用总结
    linux定时器的实现方法
    Socket的长连接和短连接
    记录各种材质的数据
    max导出模型插件
    鸡汤 -心灵 记录
    UGUI 加载图片
    u3d udp服务器
  • 原文地址:https://www.cnblogs.com/gaojian/p/2683394.html
Copyright © 2011-2022 走看看