[previous] 0305 [next] [I] Cast between a pointer to function and an integral type.
Pointers REFERENCE - ISO:C90-6.3.4 Cast Operators - Semantics

A cast is being performed between an integral type and a pointer to function type, or vice versa.

Any cast which maps integer values to pointer values is by nature implementation-defined. When casting from a pointer type to an integer type, the size of integer which is required will also be implementation defined. However this type of operation is not uncommon in embedded software applications.

For example:


/*PRQA S 2017,2211,3120,3199,3203,3408,3447,3672 ++*/

extern int (* pf)(int x);


extern void foo(void)
{
    unsigned short mus;
    unsigned long mul;

    pf = (int (*)(int x))0xC000U;               /* Message 0305          */

    mul = (unsigned long)pf;                    /* Message 0305          */

    mus = (unsigned short)pf;                   /* Message 0305 and 0309 */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents