• <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-05-25來源:作者:點擊數: 標簽:怪的定義參數解答一個
    一個奇怪的函數參數定義及解答 關于一個奇怪的函數參數定義及解答 問題來源于:濤濤的blog:http://www.sysinfo.cn/index.php?action=showid=297page=1#cm433 解答:kernelxu:http://blog.chinaunix.net/index.php?blogId=5727 一個奇怪的函數參數定義及解答

    一個奇怪的函數參數定義及解答

    關于一個奇怪的函數參數定義及解答

    問題來源于:濤濤的blog:http://www.sysinfo.cn/index.php?action=show&id=297&page=1#cm433

    解答:kernelxu:http://blog.chinaunix.net/index.php?blogId=5727

    一個奇怪的函數參數定義及解答

    奇怪的參數聲明:

    unsigned int str_len(s)
    register char *s;
    {
      register char *t;

      t = s;
      for (;;) {
        if (!*t) return t - s; ++t;
        if (!*t) return t - s; ++t;
        if (!*t) return t - s; ++t;
        if (!*t) return t - s; ++t;
      }
    }

    試了一下編譯可以通過,也可以正常運行...

    估計跟

    unsigned int str_len(register char *s)
    {
      register char *t;

      t = s;
      for (;;) {
        if (!*t) return t - s; ++t;
        if (!*t) return t - s; ++t;
        if (!*t) return t - s; ++t;
        if (!*t) return t - s; ++t;
      }
    }

    是等價的...

    可是不知道為什么要來四次if (!*t) return t - s; ++t;

    不知道跟一次有什么區別...

    ——————————————————————————————————

    我的解答:

    1、是老板本的C吧,在老版本C語言中,參數類型說明允許放在函數說明部分的第2行單獨指定。

    例如:

    int fun(s)

    int s;

    {

    ...

    }
    2、這里寫四條 if (!*t) return t - s; ++t;可能是考慮到處理器采用流水線結構。早期經典的奔騰有5級流水線結構,奔騰II有12級超流水線結構,而Pentium 4的流水線就長達20級。而經典奔騰每條整數流水線都分為四級流水,即指令預取、譯碼、執行、寫回結果,浮點流水又分為八級流水。

    (關于流水線可查看:

    1)、CPU的流水線:

    http://www.blueidea.com/bbs/NewsDetail.asp?id=1821795)

    2)、pipeline較詳細說明:

    http://www.cs.umass.edu/~weems/CmpSci535/Discussion16.html

    3)、《Starting Down the Pipeline》:http://faculty.uwb.edu/aberger/CSS422SP05/Articles/Pipelines%20part%201%20and%202.pdf

    4)、The Intel Pentium 4 processor 20 stages of pipeline introduce:

    http://www.karbosguide.com/hardware/module3e14.htm


    這里是地址的運算,所以我猜想可能是這個原因吧。

    不知道是不是這樣,請高手指點!

    原文轉自: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>