Changeset 581

Show
Ignore:
Timestamp:
08/15/08 17:20:06
Author:
rachel
Message:

Ben's new suggested way of doing DECONST

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openpgpsdk/trunk/include/openpgpsdk/util.h

    r570 r581  
    4040 
    4141/* typesafe deconstification */ 
     42#ifdef OBSOLETE 
    4243#ifdef WIN32 
    4344static void *_deconst(const void *p) 
     
    4748    { return (void *)p; } 
    4849#endif 
    49 #define DECONST(type,p) (((type *(*)(const type *))ops_fcast(_deconst))(p)) 
     50#endif /*OBSOLETE*/ 
     51 
     52/* 
     53 * These macros code ensures that you are casting what you intend to cast. 
     54 * It works because in "a ? b : c", b and c must have the same type. 
     55 */ 
     56#define CHECKED_PTR_OF(type, p) \ 
     57    ((void*) (1 ? p : (type *)0))  
     58#define DECONST(type,p) ((type *)CHECKED_PTR_OF(const type, p)) 
    5059 
    5160char *ops_str_from_map(int code, ops_map_t *map);