hpp
来源:互联网 发布:红旗linux桌面版 编辑:程序博客网 时间:2024/05/01 08:42
hpp,顾名思义等于.h加上.cpp,在boost、Xerces等开源库中频繁出现,偶在机缘巧合之下,学得一招半式,遂记录如下,以供参考学习。
I use .hpp because I want the user to differenciate what headers are C++ headers, and what headers are C headers.
This can be important when your project is using both C and C++ modules: Like someone else explained before me, you should do it very carefully, and its starts by the "contract" you offer through the extension
.hpp : C++ Headers
(Or .hxx, or .hh, or whatever)
This header is for C++ only.
If you're in a C module, don't even try to include it. You won't like it, because no effort is done to make it C-friendly (too much would be lost, like function overloading, namespaces, etc. etc.).
.h : C/C++ compatible or pure C Headers
This header can be included by both a C source, and a C++ source, directly or indirectly.
It can included directly, being protected by the __cplusplus
macro:
- Which mean that, from a C++ viewpoint, the C-compatible code will be defined as
extern "c"
. - From a C viewpoint, all the C code will be plainly visible, but the C++ code will be hidden (because it won't compile in a C compiler).
For example:
#ifndef MY_HEADER_H#define MY_HEADER_H #ifdef __cpluplus extern "C" { #endif void myCFunction() ; #ifdef __cpluplus } // extern "C" #endif#endif // MY_HEADER_H
Or it could be included indirectly by the corresponding .hpp header enclosing it with the extern "c"
declaration.
For example:
#ifndef MY_HEADER_HPP#define MY_HEADER_HPPextern "C"{#include "my_header.h"}#endif // MY_HEADER_HPP
and:
#ifndef MY_HEADER_H#define MY_HEADER_Hvoid myCFunction() ;#endif // MY_HEADER_H
- HPP
- hpp
- hpp
- .hpp
- HPP
- HPP
- hpp
- hpp文件
- hpp h
- array.hpp
- string_util.hpp
- hpp学习
- HPP文件
- hpp/cpp
- .hpp文件
- hpp文件
- hpp文件
- hpp含义
- [python相关]BaseHTTPServer -- 基本的 HTTP 服务器
- SPRING.NET 1.3.2 学习7--使用外部对象和内部对象
- GYP 简介
- intent.setFlags方法中的参数值含义
- Shuffle Error: Exceeded MAX_FAILED_UNIQUE_FETCHES; bailing-out.
- hpp
- F2812 外部中断及其中断问题
- Cortex-M3和Cortex-M4 Fault异常应用之二 ----- Fault处理函数的实现
- HtmlAgilityPack 抓取中文页面乱码问题的解决方案
- 如何设置Windows 7远程桌面连接
- 获取Iphone中的联系人
- spring-mvc访问静态资源iO类
- Android: Disable Highlight Color Of ListView On Click
- tomcat 设置默认项目