Assigning values to a struct pointer in a function: Compiler Error invalid use of incomplete type ‘struct xyz’ [closed]

I have defined a struct in a header file as

ekd_api.h

#include <stdint.h>
struct udp_rx_data_filter_lookup {
        uint16_t        connection_idx;
}

Now I have created a function in a ekd_api.cpp file

#include "ekd_api.h"
uint32_t qbit_set_udp_rx_connection_idx(uint32_t port_id, struct udp_rx_data_filter_loopkup* _udp_rx_data_filter_loopkup, uint32_t count, uint32_t *extra_info)
{
        port_id = 0;

        _udp_rx_data_filter_loopkup->connection_idx = 1;

}

Now when I am trying to compile this as gcc xyz.cpp compiler gives me following error

ekd_api.cpp:6:29: error: invalid use of incomplete type ‘struct udp_rx_data_filter_loopkup’
    6 |  _udp_rx_data_filter_loopkup->connection_idx = 1;
      |                             ^~
ekd_api.cpp:2:66: note: forward declaration of ‘struct udp_rx_data_filter_loopkup’
    2 | uint32_t qbit_set_udp_rx_connection_idx(uint32_t port_id, struct udp_rx_data_filter_loopkup* _udp_rx_data_filter_loopkup, uint32_t count, uint32_t *extra_info)

Please help me here. Thanks



Read more here: https://stackoverflow.com/questions/64943855/assigning-values-to-a-struct-pointer-in-a-function-compiler-error-invalid-use-o

Content Attribution

This content was originally published by user3217310 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: