• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 多個文件函數互相引用的編譯操作

    發表于:2007-07-04來源:作者:點擊數: 標簽:
    在寫程序的時候,會經常遇到文件a.c會調用b.c中的某一個函數func(),那么該如何來進行操作呢?答案是:合理的利用Makefile,而不是includeb.c,否則會報undefind symbol to _func().下面是詳細的操作過程。 /*b.c*/ #includes td io.h int p=3; int func(int i)
    在寫程序的時候,會經常遇到文件a.c會調用b.c中的某一個函數func(),那么該如何來進行操作呢?答案是:合理的利用Makefile,而不是include<b.c>,否則會報undefind symbol to _func().下面是詳細的操作過程。

    /*b.c*/

    #include<stdio.h>

    int p=3;

    int func(int i)

    {return p*i;}

    int setp(int i)

    /*a.c*/

    #include<stdio.h>

    extern int p;

    extern int func(int i);

    extern int setp(int i);//告訴系統這些函數在其他的文件當中

    int main(int argc,char *argv[])

    {

        setp(4);

        printf("%d",func(4));

    }

    /*Makefile*/

    all: a

    gcc -o a.o b.o

       

    Then run make, run the programme, you will get result 16

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>