Initializing a pointer inside a struct

Paul Stachour stachour at sctc.com
Wed Apr 24 04:13:44 AEST 1991


re: the problem
>[] On 17 Apr 91 10:51:39 GMT, f90angu at fy.chalmers.se (Andreas Gunnarsson) said:

>AG> I've tried this:

>AG> struct
>AG> {
>AG>    ...
>AG>    int *int_list;
>AG>    ...
>AG> } list_of_structs[] =
>AG> {
>AG>    { ..., {1, 2, 3, -1}, ...},
>AG>    { ..., {4, -1}, ...},
>AG>    .
>AG>    .
>AG>    .
>AG> };

=====
The solution suggested was that one uses a set of statics,
and then gives the pointer to those items.
-----
Those trying the solution should be aware that many C compilers
for embedded systems (e.g, multi-tasking C programs) cannot
get the correct addresses into the initialized structures due
to the way in which the compiler and run-time startup is built.
I seldom have these problems on virtural-memory systems like Unix
or on one-process physical memory systems like MS-DOS, but nearly
every compiler I have ever used for C on top of physical-memory
multi-porcess structures gets at least one of its addressing
modes between "varieties of data" (such as static-static,
static-const, static-exec, ...) wrong.

...Paul

-- 
Paul Stachour          SCTC, 1210 W. County Rd E, Suite 100           
stachour at sctc.com          Arden Hills, MN  55112
                             [1]-(612) 482-7467



More information about the Comp.lang.c mailing list