man.bsd.lv manual page server

Manual Page Search Parameters

__UNCONST(3) Library Functions Manual __UNCONST(3)

__UNCONSTcompile time cast-away macro

#include <sys/cdefs.h>

void
__UNCONST(x);

void
__UNVOLATILE(x);

The () macro can be used to omit warnings produced by certain compilers when operating with pointers declared with the const type qualifier in a context without such qualifier. Examples include passing a pointer declared with the const qualifier to a function without such qualifier, and variable assignment from a const pointer to a non-const pointer. In the same vein, the () macro can be used to exclude warnings related to the volatile type qualifier.

These macros are implemented by explicitly using instead of , a signed type guaranteed to hold a pointer.

cc(1), cdefs(3)

As both macros may hide valid errors, their usage is not recommended unless there is a well-thought reason for a cast. A typical use case for __UNCONST() involve an API that does not follow the so-called ``const correctness'' even if it would be appropriate. Valid use cases of __UNVOLATILE() include passing a volatile pointer to memset(3).

Use of this macro is non-portable; this is part of the implementation namespace and should only be used in NetBSD code.

October 17, 2013 NetBSD-9.2