illegal cast: from struct 'socket_log_data' to 'unsigned int' data
<p>I've a function <code>logEthernetConnection()</code> which takes an integer as a parameter.
However, requirement suggests I pass a struct to it.
I've typecasted the struct while passing, yet I obtain the error as mentioned in the title:-</p>

<pre><code> error (dplus:1061): illegal cast: from 'socket_log_data' to 'unsigned int'
</code></pre>

<p>Here's the code snippet:-</p>

<pre><code>typedef struct fields
{
    UINT16 loss_reason : 1;
    UINT16 unused : 15;
} FIELDS;

typedef union fields_union
{
    UINT16 all_fields;
    FIELDS ref_fields;
    fields_union() : all_fields(0), ref_fields() {}
} FIELDS_UNION;

typedef struct socket_log_data
{
    FIELDS_UNION ref_fields_union;
    UINT16 socket_number;
    socket_log_data() : socket_number(0), ref_fields_union() {}
} SOCKET_LOG_DATA;

int logEthernetConnection(UINT32 data)
{
    return data;
}
void main()
{
    UINT32 data = logEthernetConnection((UINT32)socket_log_data);
    getchar();
}
</code></pre>

<p>How should I fix this?</p>

<p>Related query posted here:-
<a href="https://stackoverflow.com/questions/35485404/error-illegal-cast-from-int-to-union/35555859#35555859">Error: illegal cast: from &#39;int&#39; to &#39;union&#39;</a></p>