1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-21 13:05:04 -05:00

Replace the type-checking COMPTR macro with my current idea of best

practice in type-check macros.

[originally from svn r9963]
This commit is contained in:
Simon Tatham 2013-07-22 07:12:15 +00:00
parent 353b85be67
commit 0a26bd74e1

View File

@ -353,12 +353,12 @@ static const PROPERTYKEY PKEY_Title = {
0x00000002 0x00000002
}; };
/* Type-checking macro to provide arguments for CoCreateInstance() etc. /* Type-checking macro to provide arguments for CoCreateInstance()
* The pointer arithmetic is a compile-time pointer type check that 'obj' * etc, ensuring that 'obj' really is a 'type **'. */
* really is a 'type **', but is intended to have no effect at runtime. */ #define typecheck(checkexpr, result) \
(sizeof(checkexpr) ? (result) : (result))
#define COMPTR(type, obj) &IID_##type, \ #define COMPTR(type, obj) &IID_##type, \
(void **)(void *)((obj) + (sizeof((obj)-(type **)(obj))) \ typecheck((obj)-(type **)(obj), (void **)(void *)(obj))
- (sizeof((obj)-(type **)(obj))))
static char putty_path[2048]; static char putty_path[2048];