[previous] 0313 [next] Casting to different function pointer type.
Pointers REFERENCE - ISO:C90-6.3.4 Cast Operators - Semantics

An expression of type 'pointer-to-function' is being cast to a different 'pointer-to-function' type.

According to ISO:C90, the only circumstances under which a function pointer can legitimately be converted to a different function pointer type are as follows:

The circumstances under which such conversions should be necessary are not common.

For example:


/*PRQA S 0428,2017,2211,3198,3199,3203,3408,3447,3635,3672 ++*/


extern void error( long * x );

extern void foo(void)
{
    void (* pf)( int * x );
    unsigned long ulx;

    pf = (void (*)( int * x)) error;              /* Message 0313 */

    ulx = (unsigned long)&error;                  /* Message 0305 */

    pf = (void (*)( int * x)) ulx;                /* Message 0305 */

}

See also:

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