惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - domini

给年轻工程师的十大忠告 vc定时以及计时的方法 数字图像处理常用词 VC数据类型的转换 C语言 第二讲 数据类型 windows进程中的内存结构 调试方法和技巧,作者:非凡 Bitblt的参数 图像的文件格式bmp gif 怎样在内存缓冲中画图 转载 原作者 相生昌 MFC GDI双缓冲避免图形闪烁,转载 关键字 Windows API函数大全 利用GDI+的双缓冲技术来提高绘图效率 屏幕任意抓图截图 Visual C++的程序设计技巧 VC中用GDI函数实规高速平滑动画 用Visua C++6.0为灰度图像增加彩色滤镜制作"复古照" 模板匹配 API函数大全
VC里一些容易混淆的地方
domini · 2005-04-16 · via 博客园 - domini


1.FALSE/TRUE与false/true的区别:

 false/true是标准C++语言里新增的关键字,而FALSE/TRUE是通过#define,这要用途是解决程序在C与C++中环境的差异,以下是FALSE/TRUE在windef.h的定义:

#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE 1
#endif

也就是说FALSE/TRUE是int类型,而false/true是bool类型;所以两者不一样的,只不过我们在使用中没有这种感觉,因为C++会帮你做隐式转换。

2.bool的大小与BOOL的区别:

bool在C++里是占用1字节,而BOOL是int类型,int类型的大小是视具体环境而定的;所以来说:false/true只占用1个字节,而TRUE/FALSE视具体环境而言,以下是BOOL在windef.h中的定义:typedef int BOOL;

3.NULL与0的区别:

 还是让我们看一下windef.h中NULL的定义:

#ifndef NULL
#ifdef __cplusplus//这个是指示是用C++来编译程序
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif

所以说:它们没有区别,只不过在C里面会做一个强制类型转换。

4.HINSTANCE与HMODULE的区别:

在windef.h中的定义:

typedef HINSTANCE HMODULE; /* HMODULEs can be used in place of HINSTANCEs */

5.CALLBACK,WINAPI的实质:

在windef.h中的定义:

#undef far
#undef near
#undef pascal

#define far
#define near
#if (!defined(_MAC)) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
   #define pascal __stdcall
#else
   #define pascal
#endif

#if defined(DOSWIN32) || defined(_MAC)
   #define cdecl _cdecl
   #ifndef CDECL
       #define CDECL _cdecl
   #endif
#else
   #define cdecl
   #ifndef CDECL
       #define CDECL
   #endif
#endif

#ifdef _MAC
   #define CALLBACK PASCAL
   #define WINAPI CDECL
   #define WINAPIV CDECL
   #define APIENTRY WINAPI
   #define APIPRIVATE CDECL
   #ifdef _68K_
       #define PASCAL __pascal
   #else
       #define PASCAL
   #endif
#elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
       #define CALLBACK __stdcall
       #define WINAPI __stdcall
       #define WINAPIV __cdecl
       #define APIENTRY WINAPI
       #define APIPRIVATE __stdcall
       #define PASCAL __stdcall
   #else
       #define CALLBACK
       #define WINAPI
       #define WINAPIV
       #define APIENTRY WINAPI
       #define APIPRIVATE
       #define PASCAL pascal
#endif

6.一些常见类型的定义:

在windef.h中的定义:

typedef UINT WPARAM;
typedef LONG LPARAM;
typedef LONG LRESULT;

typedef int INT;
typedef unsigned int UINT;

typedef unsigned long DWORD;
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef float FLOAT;

typedef unsigned long ULONG;
typedef unsigned short USHORT;
typedef unsigned char UCHAR;
typedef char *PSZ;

7.常见Window资源类型的实质:

在windef.h中的定义:

DECLARE_HANDLE(HPEN);
DECLARE_HANDLE(HBITMAP);
DECLARE_HANDLE(HBRUSH);
DECLARE_HANDLE(HDC);
DECLARE_HANDLE(HFONT);
DECLARE_HANDLE(HICON);
DECLARE_HANDLE(HMENU);
DECLARE_HANDLE(HMETAFILE);
DECLARE_HANDLE(HINSTANCE);
DECLARE_HANDLE(HPALETTE);
typedef WORD ATOM;
typedef HANDLE HGLOBAL;
typedef HANDLE HLOCAL;
typedef HANDLE GLOBALHANDLE;
typedef HANDLE LOCALHANDLE;
typedef HICON HCURSOR; /* HICONs & HCURSORs are polymorphic */
typedef DWORD COLORREF;

在windowsx.h中:

#define DECLARE_HANDLE32 DECLARE_HANDLE

penwin.h:

#ifndef DECLARE_HANDLE32
#define DECLARE_HANDLE32(name)\
struct name##__ { int unused; };\
typedef const struct name##__ FAR* name
#endif //!DECLARE_HANDLE32 

6.Platform的编译版本的相关预处理宏:

Macro Description 
__cplusplus Defined for C++ programs only. 
_MFC_VER Defines the MFC version. Defined as 0x0421 for Microsoft Foundation Class Library 4.21. Always defined. 
_MSC_VER Defines the compiler version. Defined as 1200 for Microsoft Visual C++ 6.0. Always defined. 
_WIN32 Defined for applications for Win32®. Always defined.