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

             

            #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++程序與機器硬件和操作系統保持完全兼容而定義的宏擴展,
            #pragma是和特定編譯器相關的。)
            兩部分:
            1.Pragma說明;
            2.Pragma的語法。

            一、Pragma說明(Directives)

            C和C++程序的每次執行都支持其所在的主機或操作系統所具有的一些獨特的特點。
            一些程序,例如,需要精確控制數據存放的內存區域或控制某個函數接收的參數。
            #pragma指示為編譯器提供了一種在不同機器和操作系統上編譯以保持C和C++完全兼容的方法。?
            Pragmas是由機器和相關的操作系統定義的,通常對每個編譯器來說是不同的。


            二、語法(Syntax)

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

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

            符號(#)必須是pragma所在那一行的第一個非空格字符;
            #號和pragma之間可以有任意個空格符。
            在#pragma之后,是可以被編譯器解析的預處理特征字符。
            一般認為,#pragma屬于宏擴展。
            如果編譯器發現不認識的pragma,會提出警告,但繼續編譯下去。

            Pragmas可以用在條件聲明上,提供最新的功能性的預處理程序,或者提供給編譯器定義執行的信息。
            C和C++編譯器認可如下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


            這是MSDN的一篇文章,原作者曾經想使用
            #pragma pack(1) // 用GCC在MIPS平臺上將結構體成員結合到一塊連續的內存塊,但是沒有做到。

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

            建議參考具體編譯器的文檔,在里面應該有pragma的說明。

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

            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) 評論(0)  編輯 收藏 引用 所屬分類: C++

            <2008年1月>
            303112345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿(22)

            隨筆分類(30)

            隨筆檔案(29)

            文章分類

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            日本免费一区二区久久人人澡| 日产精品99久久久久久| 亚洲一本综合久久| 久久伊人影视| 97久久精品午夜一区二区| 久久丝袜精品中文字幕| 性欧美丰满熟妇XXXX性久久久| 狠狠色丁香久久综合婷婷| 久久久久久亚洲精品不卡| 久久青青草原亚洲av无码app| 久久精品无码一区二区三区日韩 | 国产免费久久久久久无码| 久久精品国产一区二区三区不卡| 久久亚洲中文字幕精品一区| 久久综合狠狠综合久久| 日本亚洲色大成网站WWW久久| 无码国内精品久久人妻蜜桃| 国内精品久久久久久不卡影院| 亚洲精品乱码久久久久久久久久久久| 久久91精品国产91久久麻豆| 亚洲欧美一区二区三区久久| 97精品伊人久久久大香线蕉| 久久精品国产清高在天天线| 久久无码国产| 国产91色综合久久免费| 久久精品国产亚洲AV大全| 久久综合亚洲鲁鲁五月天| 久久青青草原精品国产软件 | 无码乱码观看精品久久| 婷婷久久综合九色综合98| 亚洲综合熟女久久久30p| 久久免费国产精品| 精品久久久久中文字| 99久久久精品| 久久伊人精品青青草原高清| 久久国产精品成人片免费| 久久久噜噜噜久久中文字幕色伊伊 | 色综合久久久久综合体桃花网| 日日狠狠久久偷偷色综合96蜜桃| 久久综合综合久久97色| 99久久国产亚洲高清观看2024|