• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            浪跡天涯

            唯有努力...
            努力....再努力...

            pragma指令

            #pragma指令對(duì)每個(gè)編譯器給出了一個(gè)方法,在保持與c,c++語(yǔ)言完全兼容的情況下, 
            給出主機(jī)或操作系統(tǒng)專有的特征。依據(jù)定義,編譯指示是機(jī)器或操作系統(tǒng)專有的,且 
            對(duì)每個(gè)編譯器都是不同的。 
            #pragma#pragma是語(yǔ)言符號(hào)字符串。它是給出特有編譯器指令和參量的字符序列。在 
            pragma后,可以編寫翻譯器作為預(yù)處理語(yǔ)言符號(hào)分析的任何文本。#pragma從屬于宏擴(kuò)展。 
            #pragma后跟不同的編譯指令可實(shí)現(xiàn)不同的功能。這里列出它的幾個(gè)用法: 
            1.#pragma  comment(comment-type,[string])可將一個(gè)注視記錄放入一個(gè)對(duì)象文件或可執(zhí) 
               行文件中。 
            2.#pragma  init_seg({complier/lib/user/  "section-name  "[,  "func-name]]}) 
               該指令制定一個(gè)影響啟動(dòng)代碼實(shí)行順序的關(guān)鍵字或代碼段。 
            3.#pragma  pointers_to_members 
               該指令制定一個(gè)類成員的指針能否在其相關(guān)定義之前被說(shuō)明,且用于控制該指針尺寸和 
               解釋該指針需要的代碼。 
            4..#pragma  pack([n)] 
               該指令制定結(jié)構(gòu)和聯(lián)合成員的緊湊對(duì)齊。

             

            #pragma TRAP_PROC
            interrupt void isrTIM1(void)
            {
             // 17KHz 59us 加檔肺 牢磐反飄
             zTimer_++;
             COP_REFRESH;  // {asm sta aCOPCTL;}
             TIM1_FLAG_CLEAR; // READ_REG(aT1SC) // TOF1 甫 Clear
            }

            Pragma是什么?

            Pragma是什么?
            翻譯:SkyJacker
            后附英文原文。


            (譯者注:
            一句話,pragma就是為了讓編譯器編譯出的C或C++程序與機(jī)器硬件和操作系統(tǒng)保持完全兼容而定義的宏擴(kuò)展,
            #pragma是和特定編譯器相關(guān)的。)
            兩部分:
            1.Pragma說(shuō)明;
            2.Pragma的語(yǔ)法。

            一、Pragma說(shuō)明(Directives)

            C和C++程序的每次執(zhí)行都支持其所在的主機(jī)或操作系統(tǒng)所具有的一些獨(dú)特的特點(diǎn)。
            一些程序,例如,需要精確控制數(shù)據(jù)存放的內(nèi)存區(qū)域或控制某個(gè)函數(shù)接收的參數(shù)。
            #pragma指示為編譯器提供了一種在不同機(jī)器和操作系統(tǒng)上編譯以保持C和C++完全兼容的方法。?
            Pragmas是由機(jī)器和相關(guān)的操作系統(tǒng)定義的,通常對(duì)每個(gè)編譯器來(lái)說(shuō)是不同的。


            二、語(yǔ)法(Syntax)

            #pragma token-string(特征字符串)

            特征字符串是一連串的字符,就是要給一個(gè)特定編譯器提供說(shuō)明和編譯意見。

            符號(hào)(#)必須是pragma所在那一行的第一個(gè)非空格字符;
            #號(hào)和pragma之間可以有任意個(gè)空格符。
            在#pragma之后,是可以被編譯器解析的預(yù)處理特征字符。
            一般認(rèn)為,#pragma屬于宏擴(kuò)展。
            如果編譯器發(fā)現(xiàn)不認(rèn)識(shí)的pragma,會(huì)提出警告,但繼續(xù)編譯下去。

            Pragmas可以用在條件聲明上,提供最新的功能性的預(yù)處理程序,或者提供給編譯器定義執(zhí)行的信息。
            C和C++編譯器認(rèn)可如下pragmas:
            alloc_text
            comment //注釋
            init_seg1 
            optimize  //最優(yōu)化
            auto_inline
            component  //組成部件
            inline_depth
            pack       //包
            bss_seg
            data_seg
            inline_recursion  //內(nèi)嵌遞歸
            pointers_to_members1
            check_stack
            function   
            intrinsic  //內(nèi)在的
            setlocale
            code_seg
            hdrstop
            message 
            vtordisp1
            const_seg
            include_alias
            once
            warning


            這是MSDN的一篇文章,原作者曾經(jīng)想使用
            #pragma pack(1) // 用GCC在MIPS平臺(tái)上將結(jié)構(gòu)體成員結(jié)合到一塊連續(xù)的內(nèi)存塊,但是沒有做到。

            在linux環(huán)境下使用intel-based GCC,#pragma pack(1)可以工作。

            建議參考具體編譯器的文檔,在里面應(yīng)該有pragma的說(shuō)明。

            ---------------------------------------原文-------------------------------------------

            Pragma Directives
            Each implementation of C and C++ supports some features unique to its host machine or operating system.

            Some programs, for instance, need to exercise precise control over the memory areas where data is placed or

            to control the way certain functions receive parameters.
            The #pragma directives offer a way for each compiler
            to offer machine- and operating-system-specific features
            while retaining overall compatibility with the C and C++
            languages. Pragmas are machine- or operating-system-specific by definition,
            and are usually different for every compiler.

            Syntax

            #pragma token-string

            The token-string is a series of characters that gives a specific compiler instruction and arguments,
            if any.

            The number sign (#) must be the first non-white-space character on the line containing the pragma;

            white-space characters can separate the number sign and the word pragma.
            Following #pragma, write any text that the translator can parse as preprocessing tokens.
            The argument to #pragma is subject to macro expansion.

            If the compiler finds a pragma it does not recognize, it issues a warning, but compilation continues.

            Pragmas can be used in conditional statements, to provide new preprocessor functionality,
            or to provide implementation-defined information to the compiler.
            The C and C++ compilers recognize the following pragmas:

            alloc_text comment init_seg1 optimize
            auto_inline component inline_depth pack
            bss_seg data_seg inline_recursion pointers_to_members1
            check_stack function intrinsic setlocale
            code_seg hdrstop message vtordisp1
            const_seg include_alias once warning


            This is an article from MSDN, I ever wanted to use
            #pragma pack(1) //which can combine structure members to one continuous memory block
            on MIPS platform using GCC, but it doesn't work.


            See the compiler's document, it should be illustrated there.

            Under linux env using intel-based GCC, it works.

            posted on 2008-01-21 15:56 浪跡天涯 閱讀(3422) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C++

            <2014年6月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(22)

            隨筆分類(30)

            隨筆檔案(29)

            文章分類

            搜索

            積分與排名

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            狠狠色综合网站久久久久久久| 久久久国产精华液| 久久本道久久综合伊人| 色综合合久久天天给综看| 久久综合亚洲鲁鲁五月天| 亚洲精品美女久久久久99| 国产成人久久777777| 久久乐国产综合亚洲精品| 国产精品久久久天天影视| 亚洲色欲久久久久综合网| 999久久久国产精品| 久久精品无码一区二区WWW| 久久久久久久99精品免费观看| 久久笫一福利免费导航| 88久久精品无码一区二区毛片 | 99精品国产综合久久久久五月天| 少妇内射兰兰久久| 久久亚洲高清综合| 久久精品无码午夜福利理论片 | 欧美一区二区精品久久| 久久国产精品国产自线拍免费| 97久久精品人人做人人爽| 中文字幕久久波多野结衣av| 99久久免费国产精精品| 精品久久久久久久国产潘金莲 | 国产精品成人精品久久久| 国产成人久久精品一区二区三区 | 国产A三级久久精品| 久久综合精品国产一区二区三区 | 亚洲&#228;v永久无码精品天堂久久| 久久青青草原精品国产| 亚洲国产精品无码成人片久久| 四虎影视久久久免费观看| 理论片午午伦夜理片久久 | 青青草国产精品久久| 久久精品夜夜夜夜夜久久| 99久久精品午夜一区二区| 国产精品久久久久久一区二区三区| 99久久精品午夜一区二区| 日韩欧美亚洲综合久久影院d3| 91久久香蕉国产熟女线看|