char *** initialization and compiler problem
chris at mimsy.UUCP
chris at mimsy.UUCP
Sat Mar 14 07:40:47 AEST 1987
In article <1721 at plus5.UUCP> hokey at plus5.UUCP (Hokey) writes:
>First, I have been *unable* to initialize the master table in any way other
>than that in the example below. I tried *lots* of combinations of braces.
I am not quite sure what you want, but the example is correct.
>Second, the *only* declaration acceptable to the compiler for the given
>initialization of the table is the one below.
Not surprising: it is the correct one.
condensed:
>extern char *sys_errlist[]; /* as per perror(3C) */
>char *a_list[] = { ... };
>char *b_list[] = { ... };
The types of `sys_errlist', `a_list', and `b_list' are each `array
<n> of pointer to char' (<n> varies, being `unknown', 7, and 5, I
think, though I have deleted the actual initialisations). When
used in ordinary expression contexts, the types are converted to
`pointer to pointer to char'. Thus:
>char **em_t[] = {
> sys_errlist,
> a_list, /* Just try and initialize with strings here! */
> b_list,
> 0
>};
`em_t' is `array 4 of pointer to pointer to char'.
Given the comment after `a_list', I guess that you might want, e.g.,
something more like this:
char **em_t[] = {
sys_errlist,
/*
* magic unnamed list:
(char *[] = { "a0", "a1", "a2", ..., 0 }),
* and another, `b', list.
*/
0
};
Alas, there is no C construct that creates an unnamed block of
initialised data space (an object of type `array <n> of <type>')
save for anonymous arrays of char, which are created with "string".
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP: seismo!mimsy!chris ARPA/CSNet: chris at mimsy.umd.edu
More information about the Comp.lang.c
mailing list