Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

forward declare typedef'd struct

I can't figure out how to forward declare a windows struct. The definition is

typedef struct _CONTEXT
{
 ....
} CONTEXT, *PCONTEXT

I really don't want to pull into this header, as it gets included everywhere.

I've tried

struct CONTEXT

and

struct _CONTEXT

with no luck (redefinition of basic types with the actuall struct in winnt.h.

like image 497
Steve Avatar asked Dec 28 '22 23:12

Steve


1 Answers

extern "C" { typedef struct _CONTEXT CONTEXT, *PCONTEXT; }

You need to declare that _CONTEXT is a struct. And declare it as extern "C" to match the external linkage of windows.h (which is a C header).

However, you don't need to provide a definition for a typedef, but if you do, all definitions must match (the One Definition Rule).

EDIT: I also forgot the extern "C".

like image 195
MSN Avatar answered Jan 10 '23 22:01

MSN