This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

elements of XHUGE structs

Hi Folks,

I do have some trouble with huge memory model and xhuge structures.

I wonder, how is it with structures of type xhuge, which constists of a lot of sub- structure types:

struct big
{
char amem[65000];
char bmem[65000];
char cmem[65000];
} xhuge st;

I do have functions get passed pointers to the substructures like this:

void dothat(char * pcStr) {}

I call the function like this:
dothat(&st.amem[8]);

Because of some strange errors in my system I wonder whether I should call the function with this cast:

dothat((char*)&st.amem[8]);

do get the xhuge type of struct st out of the way.

In common: how is it with assignments of a variable of type xhuge to one of type huge? I do this often in my code and the compiler gives no warning when doing that.

A little bit confused.
Mike

Parents
  • I wonder whether I should call the function with this cast: [...] do get the xhuge type of struct st out of the way.

    No you shouldn't. More generally speaking, casting a pointer to get some perceived obstacle "out of the way" is almost guaranteed to be the wrong approach to any problem.

    Make sure you have correct declarations for all functions, types and variables in scope, and the problem will either solve itself, or the compiler will inform you that you're tyring something impossible --- or you've hit a compiler bug.

Reply
  • I wonder whether I should call the function with this cast: [...] do get the xhuge type of struct st out of the way.

    No you shouldn't. More generally speaking, casting a pointer to get some perceived obstacle "out of the way" is almost guaranteed to be the wrong approach to any problem.

    Make sure you have correct declarations for all functions, types and variables in scope, and the problem will either solve itself, or the compiler will inform you that you're tyring something impossible --- or you've hit a compiler bug.

Children