FreeRDP
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
Functions
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
Functions
a
c
d
e
f
g
i
o
r
s
t
Variables
a
b
c
d
e
g
i
l
m
n
o
p
r
s
t
u
v
Files
File List
Globals
All
Typedefs
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Modules
Pages
Loading...
Searching...
No Matches
cast.h
1
20
#pragma once
21
22
#include <stdint.h>
23
24
#include <winpr/assert-api.h>
25
30
#ifdef __cplusplus
31
#define WINPR_CXX_COMPAT_CAST(t, val) static_cast<t>(val)
32
#else
33
#define WINPR_CXX_COMPAT_CAST(t, val) (t)(val)
34
#endif
35
36
#if defined(__GNUC__) || defined(__clang__)
44
#define WINPR_REINTERPRET_CAST(ptr, srcType, dstType) \
45
__extension__({ \
46
union \
47
{ \
48
srcType src; \
49
dstType dst; \
50
} cnv; \
51
WINPR_STATIC_ASSERT(sizeof(srcType) == sizeof(dstType)); \
52
cnv.src = ptr; \
53
cnv.dst; \
54
})
55
63
#define WINPR_CAST_CONST_PTR_AWAY(ptr, dstType) \
64
__extension__({ \
65
union \
66
{ \
67
__typeof(ptr) src; \
68
dstType dst; \
69
} cnv; \
70
cnv.src = ptr; \
71
cnv.dst; \
72
})
73
81
#define WINPR_FUNC_PTR_CAST(ptr, dstType) \
82
__extension__({ \
83
union \
84
{ \
85
__typeof(ptr) src; \
86
dstType dst; \
87
} cnv; \
88
WINPR_STATIC_ASSERT(sizeof(dstType) == sizeof(__typeof(ptr))); \
89
cnv.src = ptr; \
90
cnv.dst; \
91
})
92
93
#else
94
#define WINPR_REINTERPRET_CAST(ptr, srcType, dstType) (dstType) ptr
95
#define WINPR_CAST_CONST_PTR_AWAY(ptr, dstType) (dstType) ptr
96
#define WINPR_FUNC_PTR_CAST(ptr, dstType) (dstType)(uintptr_t) ptr
97
#endif
98
99
#if defined(__GNUC__) || defined(__clang__)
100
111
#define WINPR_ASSERTING_INT_CAST(type, var) \
112
__extension__({ \
113
WINPR_ASSERT((var) == \
114
WINPR_CXX_COMPAT_CAST(__typeof(var), WINPR_CXX_COMPAT_CAST(type, (var)))); \
115
WINPR_ASSERT((((var) > 0) && (WINPR_CXX_COMPAT_CAST(type, (var)) > 0)) || \
116
(((var) <= 0) && WINPR_CXX_COMPAT_CAST(type, (var)) <= 0)); \
117
WINPR_CXX_COMPAT_CAST(type, (var)); \
118
})
119
120
#else
121
#define WINPR_ASSERTING_INT_CAST(type, var) WINPR_CXX_COMPAT_CAST(type, var)
122
#endif
winpr
include
winpr
cast.h
Generated by
1.9.8