_PAYLOAD_OF()

QNX SDP8.0C Library ReferenceAPIDeveloper

Generate a pointer to the payload that follows the specified header member of an object

Synopsis:

#include <stddef.h>

void* _PAYLOAD_OF(obj, hdr_member);

Arguments:

obj
A pointer to an object that contains both header and payload data. The referenced type of this pointer must define the member specified by the hdr_member parameter, but need not define any member(s) to represent the payload.
hdr_member
The object member that represents the fixed-size header that precedes the payload. This parameter is similar to the second parameter of the offsetof() macro, but while offsetof() returns the offset to the start of the specified member of an object, __PAYLOAD_OF() returns a pointer to the location that immediately follows that member. The specified header member may be offset from the start of the referenced type of obj, and may be defined within one or more sub-structures and/or sub-unions.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The _PAYLOAD_OF() macro generates a pointer to the payload that follows the specified header member of the specified object. This pointer has the same type and value as the expression ((void *)(&(obj)->hdr_member + 1)), but for the purposes of object size determination, the compiler associates it with the same object bounds as the obj pointer. Use the _PAYLOAD_OF() macro to avoid or work around false positive buffer overflow failures when compiling with the _FORTIFY_SOURCE feature enabled at a level greater than 1.

Returns:

A pointer to the variable-length payload that follows the specified header member.

Classification:

QNX OS

Safety:
Cancellation pointYes
Signal handlerYes
ThreadYes
Page updated: