i have a struct defined as
typedef struct BSP_AREA {
struct BSP_AREA *otherBspArea; /* Pointer to itself */
long BSPReturnCode;
short sGroupNum; /* default to 0 */
char filler4[6]; /* alignment bytes */
unsigned char byCobolWorkArea[20]; /* Cobol Work Area */
// .... and lots of others fields
} * PBSP_PASS ;
So basically a BSP_AREA
can hold a pointer reference to itself, to create a sort of link list.
In the code, i have a method createNode()
which returns a BSP_AREA
with method signature BSP_AREA createNode()
. So in this method i just initialize a BSP_AREA
and return it. Now after calling this method, to set the pointer it contains to itself i am doing this, but getting an error.
BSP_AREA cobolPassArea2 = createNode(data1);
cobolPassArea->otherBspArea = &cobolPassArea2;
How do i initialize the pointer otherBSP to the BSP_PASS_AREA
returned from createNode()
? Please dont advise to make createNode return a pointer, instead of a concrete BSP_AREA
, as this is the requirement.