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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - Evilbaniry

(转)浏览器的两种模式quirks mode 和strict mode Does a Nodelist contain circle? XML Dom所有的节点类型 ExtJS-2.2内存泄漏补丁 (转)VC中#pragma warning指令 #define总结 (网上资料汇集) 自已为Ext添加的DateTimeField控件(附源码) (转)GetWindowLongPtr释义 (转)消息分流器 (转)std::map的用法总结 GetModuleFileName()得到程序路径 利用GetDriveType来得到驱动器信息 - Evilbaniry makeintresource:VC MAKEINTRESOURCE 析疑 (转)c/c++的预处理定义 Stringizing Operator (#) Charizing Operator (#@) Token-Pasting Operator (##) va_start() va_end()函数应用 #ifdef __cplusplus 倒底是什么意思? - Evilbaniry (转)typedef用法小结 (转)STDAPI释义 判断windows系统类型
VC里一些容易混淆的地方(转)
Evilbaniry · 2009-02-23 · via 博客园 - Evilbaniry

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的编译版本的相关预处理宏:

MacroDescription__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.

posted on 2009-02-23 22:41  Evilbaniry  阅读(675)  评论()    收藏  举报