I'm trying to add a socket filter to one of my sockets in C++ (Linux). In the socket filter I need to get the offset of struct fork_proc_event, which is nested within another structure. The definition looks like this (cn_proc.h):
struct proc_event { ... union { ... struct fork_proc_event { __kernel_pid_t parent_pid; ... } fork; ... } event_data; ... };
In C I would do this:
int off = offsetof(struct fork_proc_event, parent_pid);
However I'm developing in C++. If I try to do this:
int off = offsetof(proc_event::fork_proc_event, parent_pid);
I get the following error:
error: expected type-specifier error: expected `,' error: expected `)' before ',' token
How should the offsetof() line look like?