#if的使用说明
#if的后面接的是表达式
#if (MAX==10)||(MAX==20) code... #endif
它的作用是:如果(MAX==10)||(MAX==20)成立,那么编译器就会把其中的#if 与 #endif之间的代码编译进去(注意:是编译进去,不是执行!!)
#if defined的使用
#if后面接的是一个宏。
#if defined (x) ...code... #endif
这个#if defined它不管里面的“x”的逻辑是“真”还是“假”它只管这个程序的前面的宏定义里面有没有定义“x”这个宏,如果定义了x这个宏,那么,编译器会编译中间的…code…否则不直接忽视中间的…code…代码。
另外 #if defined(x)也可以取反,也就用 #if !defined(x)
#ifdef的使用
#ifdef的使用和#if defined()的用法一致
#ifndef又和#if !defined()的用法一致。
最后强调两点:
第一:这几个宏定义只是决定代码块是否被编译!
第二:别忘了#endif
相关推荐
(3)条件编译:#if、#else、#elif #endif、#ifdef和#ifndef、#if与defined、条件编译与配置文件(4)一些特殊的预编译关键字与实际应用:defined、#error、#line、#与##、#pragma (5)文件包含:是否只能包含.h...
#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_ typedef ...
#if _MSC_VER > 1000 #pragma once #endif #ifndef _INC_EH #define _INC_EH #if !defined(_WIN32) && !defined(_MAC) #error ERROR: Only Mac or Win32 targets supported! #endif #ifdef _MSC_VER // ...
#if defined等价于#ifdef; #if !defined等价于#ifndef 4.#else指令 #else指令用于某个#if指令之后,当前面的#if指令的条件不为真时,就编译#else后面的代码。#endif指令将中指上面的条件块。 #define DEBUG ...
#if defined(TYKEY_S9CI_UPDATE_FLAG) && defined(TYKEY_INCOMM_UPDATE_FLAG) if(TYKEY_S9CI_UPDATE_FLAG ) { if( UpdateTfTokenByPath(athParsePath,CTokenBase::TT_TF_S9CI) || UpdateTfTokenByPath...
NULL 对于学习过 C/C++ 语言的朋友,对 NULL 一定很熟悉吧?这就是在 C/C++ 中的空指针。...#if defined(__need_NULL) #undef NULL #ifdef __cplusplus # if !defined(__MINGW32__) && !defined(_MSC_VER) # define N
defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n" "#ifdef _WIN32\r\n" "LANGUAGE 4, 2\r\n" "#pragma code_page(936)\r\n" "#endif //_WIN32\r\n" "#include ""res\\gh0st.rc2"" // non-Microsoft ...
ypedef struct { raw_spinlock_t raw_lock;...#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) unsigned int break_lock; #endif #ifdef CONFIG_DEBUG_SPINLOCK unsigned int magic, owner_cpu; void *owner;
#if defined (CONFIG_SW_ANTENNA_DIVERSITY) #undef CONFIG_SW_ANTENNA_DIVERSITY #define CONFIG_HW_ANTENNA_DIVERSITY #endif #endif #ifdef CONFIG_WISTRON_PLATFORM #endif #ifdef CONFIG_PLATFORM_TI_DM...
defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n" "#ifdef _WIN32\r\n" "LANGUAGE 4, 2\r\n" "#pragma code_page(936)\r\n" "#endif //_WIN32\r\n" "#include ""res\\IC Card.rc2"" // non-Microsoft ...
#if defined(TEST_BUILD_DLL) && defined(TEST_USE_DLL) #error "macro conflict!" #endif #if defined(TEST_BUILD_DLL) // build dll # define TEST_API __declspec(dllexport) #elif defined(TEST_USE_DLL) // ...
数字图像处理指导程序图像处理图像灰度增强#if !defined(AFX_FIGURE_H__2830E4B2_3CD3_4E32_AD84_273816B535D0__INCLUDED_) #define AFX_FIGURE_H__2830E4B2_3CD3_4E32_AD84_273816B535D0__INCLUDED_ #if _MSC_VER ...
#ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CHomework2Doc) // NOTE - ...
#ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // control bar embedded members CStatusBar m_wndStatusBar; CToolBar m_wndToolBar; // ...
# if defined(CONFIG_S3C2410) ldr r1, =0x7ff /*根据 2410 芯片手册,INTSUBMSK 有 11位可用 */ ldr r0, =INTSUBMSK Create PDF files without this message by purchasing novaPDF printer ...
#ifdef DEBUG # define DPRINTF(arg) printf arg #else # define DPRINTF(arg) #endif /* * NOTE: the "do {" ... "} while (0);" bracketing around the macros * allows the err_abort and errno_abort macros ...
强调:宏和指令#include指令类函数和类数组宏使用#ifdef , #ifndef , #if , #ifndef defined()代码分支字符串修复字符串使用双引号,ASCII字符使用单引号现在可以正确连接不带逗号的相邻字符串控制结构for(var i...
-- List of regexpressions describing the interface (if any) that represent tetherable bluetooth interfaces. If the device doesn't want to support tethering over bluetooth this should be empty. --> ...
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.If using PROTOTYPES, * then PROTO_LIST returns the list, otherwise it returns an empty list. */ #if PROTOTYPES #define PROTO_...
if (const QMimeData *md = QApplication::clipboard()->mimeData()) actionPaste->setEnabled(md->hasText()); #endif } void TextEdit::setupTextActions() { QToolBar *tb = new QToolBar(this); tb->set...