toppin@melpar.UUCP (Doug Toppin) (03/24/89)
We have a problem with a far pointer to a variable that has three levels of structures in it with the innermost defining a bit field. It works fine with fewer levels. I did not think that the level of embedded struct caused a different compiler action. Does anyone know what is wrong? I can find no reference to anything like this in my manuals. The smallest source that duplicates the problem follows. thanks Doug Toppin uunet!melpar!toppin /* Are three or more levels of structure depth combined with bit field definitions implied to be resolved with near pointers? We are running IBM Xenix 2 on a 286 and are having a problem that appears as if the compiler forces near pointers as deeper embedded structures are found. This creates three types, each contained within the next, it then defines a pointer to the type. The innermost structure has one variable that is 8-bits wide. Memory is allocated using 'brkctl' (which returns a far (32-bit) pointer). The 'brkctl' has nothing to do with the problem. It is only included for completeness. This is compiled with: cc -Me brkctl.c -o brkctl When this compiles the following error is returned: brkctl.c(54) : warning 60: conversion of a long address to a short address The error is the assignment line: tmp->level2.level3.a = 1; This error is generated by the compiler only if there is a bit field definition in the third or greater depth level. */ #include <stdio.h> #include <sys/brk.h> typedef struct { struct { struct { unsigned int a : 8; /* note bit field definition */ } level3; } level2; } DATA; DATA far *tmp; DATA far *brkctl(); main() { tmp = brkctl(BR_NEWSEG, 64000L, (char *) 0); /* allocate memory */ if (tmp == (DATA far *) -1) { fprintf(stderr, "Memory not available\n"); exit(1); } tmp->level2.level3.a = 1; } /* main */