Search code examples
cfunctionparametersenums

Passing a enum as a function parameter | C


I need to track where the function is calling too, so I made an enum with a list of the drivers I wish to track.

enum FPGA_IO_Type{

   A429_RX = 0,

   A429_TX = 1,

   A717_RX = 2,

   A717_TX = 3

};

now I want to put it as a function parameter

static void _function(otherData, enum FPGA_IO_Type)

and each function call looks something like this

_function(data, A429_RX);

However I get an error for "Parameter name omitted".

What am I doing wrong?


Solution

  • You are not giving it a name identifier, should be like:

    static void _function(otherData, enum FPGA_IO_Type type)
    

    likewise when you define a struct

    struct Abc
    {
       ...
    }
    

    you can put it as a parameter such as

    void function(struct Abc abc)
    {
    
    }
    

    Here enum FPGA_IO_Type and struct Abc are the types of the parameter and type and abc are the identifiers.