3.7.12. Pointer arithmetic

You can perform arithmetic on void pointers and function pointers.

The size of a void type or a function type is defined to be 1.

Mode

Supported in GNU mode for C90 and C99 only.

Errors

The compiler generates a warning if it detects arithmetic on void pointers or function pointers.

Example

int ptr_arith_0(void)
{
    void * pointer;
    return sizeof *pointer;
}

int ptr_arith_1(void)
{
    static int diff;

    diff = ptr_arith_0 - ptr_arith_1;

    return sizeof ptr_arith_0;
}
Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential