<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > 混合使用C、C++和匯編語(yǔ)之:在C++中使用C頭文件

混合使用C、C++和匯編語(yǔ)之:在C++中使用C頭文件

作者: 時(shí)間:2013-09-30 來(lái)源:網(wǎng)絡(luò ) 收藏

12.3在++中使用

本節描述如何在++代碼中使用C。從調用C之前,C頭文件必須包含在externC命令中。本節包含以下兩部分內容:

本文引用地址:http://dyxdggzs.com/article/257032.htm

·在中使用系統的C頭文件;

·在中使用自定義的C頭文件。

12.3.1在C++中使用系統C頭文件

要包括標準的系統C頭文件,如stdio.h,不必進(jìn)行任何特殊操作。只有使用externC命令,由編譯器自動(dòng)包含標準C頭文件。例如:

#includestdio.h>

intmain()

{

...//C++代碼

return0;

}

如果使用此語(yǔ)法包含頭文件,則所有庫名都放在全局命名空間中。

C++標準規定可以通過(guò)特定的C++頭文件獲取C頭文件。這些文件與標準C頭文件一起安裝在install_directoryRVCTData2.0build_numincludeplatform目錄下,可以用常規方法進(jìn)行引用。例如:

#includecstdio>

intmain()

{

...//C++代碼

return0;

}

C++中,這些頭文件中包含(#include)C頭文件。如果使用此語(yǔ)法包含頭文件,則所有C++標準庫名都在命名空間std中定義,包括C庫名。這意味著(zhù)必須使用下列方法之一來(lái)限定所有的庫名稱(chēng)。

·指定標準命名空間,例如:

std::printf(examplen);

·使用C++關(guān)鍵字“using”向全局命名空間輸入一個(gè)名稱(chēng):

usingnamespacestd;

printf(examplen);

·使用編譯程序選項--using_std。

12.3.2在C++中使用自定義的C頭文件

要包含自己的C頭文件,用戶(hù)必須將#include命令包在externC語(yǔ)句中??梢杂靡韵路椒ㄍ瓿纱瞬僮鳎?/p>

①在#include文件之前使用extern,如下例所示。

//C++code

externC{

#includemy-header1.h

#includemy-header2.h

}

intmain()

{

//...

return0;

}

·將externC語(yǔ)句添加到頭文件,如下例所示。

/*Cheaderfile*/

#ifdef__cplusplus/*InsertstartofexternCconstruct*/

externC{

#endif

/*Bodyofheaderfile*/

#ifdef__cplusplus/*InsertendofexternCconstruct*/

}/*TheCheaderfilecannowbe*/

#endif/*includedineitherCorC++code.*/

c++相關(guān)文章:c++教程




關(guān)鍵詞: C C++ 匯編 頭文件 ARM

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>