[previous] 1431 [next] An enum object is being passed as argument to a function parameter of non-enum type.
Arithmetic type - Enum types REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers

An enum object is being passed as an argument to a function which has a parameter which is not of enum type.

This is perfectly legal, but perhaps the parameter should be defined with enum type ?

For example:


/*PRQA S 2017,2211,2213,3199,3203,3227,3408,3447,3448,3602 ++*/

typedef enum TC { red, green, blue, yellow } COLOUR;

extern void foo1(int container);

extern int foo2(COLOUR paper)
{
    int box;

    box = paper;                /* Message 1432 - enum object assigned to int object     */
    foo1(paper);                /* Message 1431 - enum object passed to int parameter    */
    return paper;               /* Message 1433 - enum object returned from int function */
}

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