-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobals.h
More file actions
58 lines (44 loc) · 1.27 KB
/
Copy pathglobals.h
File metadata and controls
58 lines (44 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Module Name:
globals.h
Abstract:
Contains declarations for all globally scoped names in the program.
This file defines the CBoolean Interface Class.
Author:
Revision History:
Notes:
--*/
#pragma once
//
// SAFECAST(obj, type)
//
// This macro is extremely useful for enforcing strong typechecking on other
// macros. It generates no code.
//
// Simply insert this macro at the beginning of an expression list for
// each parameter that must be typechecked. For example, for the
// definition of MYMAX(x, y), where x and y absolutely must be integers,
// use:
//
// #define MYMAX(x, y) (SAFECAST(x, int), SAFECAST(y, int), ((x) > (y) ? (x) : (y)))
//
//
#define SAFECAST(_obj, _type) (((_type)(_obj)==(_obj)?0:0), (_type)(_obj))
//
// Bitfields don't get along too well with bools,
// so here's an easy way to convert them:
//
#define BOOLIFY(expr) (!!(expr))
//
// generic COM stuff
//
#define SafeReleaseClear(punk) \
{ \
if ((punk) != NULL) \
{ \
(punk)->Release(); \
(punk) = NULL; \
} \
}