`
- 浏览:
16092600 次
- 性别:
- 来自:
济南
-
#include_next的语意 继承和头文件
继承是对象或者文件通过拷贝其它对象或文件的内容,从而衍生出一个新的对象。对于C语言的头文件来说,继承就是一个头文件包含另一个头文件,然后更改(如更改一些宏的值)或增加一些内容。
如果衍生头文件和基础头文件(base header file)的文件名不同,处理方法很简单,只需在衍生头文件中包含基础头文件即可#include "basic"(base指代基础头文件的文件名)。
有时候我们需要使衍生出来的头文件和基础头文件的文件名相同。例如一个应用程序需要使用系统头文件sys/signal.h,但是在某些系统上/usr/include/sys/signal.h不完全和应用程序期望的一样,那么定义一个本地("local" version)的头文件将会很方便,如定义/usr/local/include/sys/signal.h来覆盖或补充系统提供的头文件。
首先写出满足程序期望的头文件/usr/local/include/sys/signal.h,然后在编译时增加"-I /usr/local/include"选项。但是如果要在新的头文件中包含标准的sys/signal.h,通过在新的文件中增加"#include <sys/signal>"是不可能实现的。因为这样包含的是文件本身而不是系统的头文件,从而导致无限的递归。
在新的头文件中增加"#include </usr/include/sys/signal.h>"固然可以解决,但是这种方式的缺点是固定了系统头文件的位置,如果系统头文件的位置改变了,这种方法就会失效。另一种简单的方法是使用"#include_next",表示包含文件名为该名字的下一个头文件。这条语句使编译器到其它目录中搜索该头文件。
继前面的例子,在头文件/usr/local/include/sys/signal.h中增加"#include_next <sys/signal.h>"就可能正确包含系统头文件了。
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
#include #include #include #include #include #include <linux/proc_fs.h> #include #include #include #include #include #include #include #ifndef VFIFO_MAJOR #define VFIFO_MAJOR 241//默认主...
#include #include #ifndef D3DXINLINE #ifdef __cplusplus #define D3DXINLINE inline #else #define D3DXINLINE _inline #endif #endif #define D3DX_DEFAULT ULONG_MAX #define D3DX_DEFAULT_FLOAT FLT_MAX ...
tHIS IS A GOOD THING I NEED
简单的C++抓屏程序,可截图 ...#define _APS_NEXT_RESOURCE_VALUE 129 #define _APS_NEXT_COMMAND_VALUE 32771 #define _APS_NEXT_CONTROL_VALUE 1005 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
代码,框架,可编译//{{NO_DEPENDENCIES}} ...#define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
#include <stl_config.h> #endif #ifndef __SGI_STL_INTERNAL_RELOPS #include <stl_relops.h> #endif #ifndef __SGI_STL_INTERNAL_PAIR_H #include <stl_pair.h> #endif #ifndef __TYPE_TRAITS_H #include <type_...
#include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of #endif // __RPCNDR_H_VERSION__ #ifndef COM_NO_WINDOWS_H #include "windows.h" #...
#include #include #define unsigned char uchar #define unsigned int uint /* 通信命令 */ #define __ACTIVE_ 0x01 // 主机询问从机是否存在 #define __GETDATA_ 0x02 // 主机发送读设备请求 #define __OK_ 0x...
#include "spmeta.h" #endif #ifndef _SLA_CHALLENGE_H_ #include "sla_challenge.h" #endif #ifndef _MULTIPORT_COMMON_H_ #include "Multiport_Common.h" #endif #ifndef _FORM_MULTILOAD_H_ #include "Form\...
#include #include #include #include #include #include #include #include #define NS_TT_START namespace tt { #define NS_TT_END } #ifdef __TIME_TRACE_DEBUG__ # define TIME_TRACE tt::record Tt_...
VS2010下FFmpeg配置文件(包含inttypes.h和stdint.h,以及修改过的common.h)。已经在Windows10上配置成功。
#include #include #define unsigned char uchar #define unsigned int uint /* 通信命令 */ #define __ACTIVE_ 0x01 // 主机询问从机是否存在 #define __GETDATA_ 0x02 // 主机发送读设备请求 #define __OK_ 0x...
#include <arpa/inet.h> /* inet_ntoa */ #include #include #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define closesocket close #define WSAGetLastError() errno #define WSACleanup
getopt.h getopt.c getopt getopt_long 字符串 转 命令行 编译通过
#include #ifdef HAVE_AIRPCAP_API #include #else #if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_) #define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ ...
#include #include #include #include #include #include //********************** #define setbit(address,bit) (address |= (1)) #define clearbit(address,bit) (address &= ~(1)) #define checkbit(address,...
#include <stdio.h> ...#define NEXTROW 12 /* 要出的下一个方块的横从标*/ #define MAXROW 14 /* 游戏屏幕大小*/ #define MAXCOL 20 #define SCCOL 100 /*游戏屏幕大显示器上的相对位置*/ #define SCROW 60
#include #include #include #include < sensor.h>#include #include #include #include #include #include #include #include < key.h >
#include #include #include #include class QTcpServer; class Cserver : public QDialog{ Q_OBJECT public: explicit Cserver(QWidget *parent = 0); ~Cserver(); private: QTcpServer *...
#include #include #include #include < sensor.h>#include #include #include #include #include #include #include #include < key.h >