problem with array of const pointers to const data 
Author Message
 problem with array of const pointers to const data

Hello,

If I declare an array in one file like so

const char* const array[] = {
"abc",
"def",
"ghi"

Quote:
};

and in another file I have

extern const char* const array[];

the linker throws up this error

error LNK2001: unresolved external symbol "char const * const * const

Does anybody know what I am doing wrong?

TIA IanM



Tue, 28 Oct 2003 22:57:10 GMT  
 problem with array of const pointers to const data

Quote:

> Hello,

> If I declare an array in one file like so

> const char* const array[] = {
> "abc",
> "def",
> "ghi"
> };

> and in another file I have

> extern const char* const array[];

> the linker throws up this error

> error LNK2001: unresolved external symbol "char const * const * const

> Does anybody know what I am doing wrong?

> TIA IanM

I can't account for the behavior, but the const on the "array" is
spurious (it's unmodifiable anyhow).  Try just:

        const char* array[];



Tue, 28 Oct 2003 23:06:36 GMT  
 problem with array of const pointers to const data
Hello Ron,

thanks for the quick response.

this all works within the same file by the way and the const on the array
does make a difference because I can reassign array[0] without it and cannot
with it.

ie

array[0] = "xyz"; // is allowed without the const

but generates a compiler error with the const

Regards IanM


Quote:


> > Hello,

> > If I declare an array in one file like so

> > const char* const array[] = {
> > "abc",
> > "def",
> > "ghi"
> > };

> > and in another file I have

> > extern const char* const array[];

> > the linker throws up this error

> > error LNK2001: unresolved external symbol "char const * const * const

> > Does anybody know what I am doing wrong?

> > TIA IanM

> I can't account for the behavior, but the const on the "array" is
> spurious (it's unmodifiable anyhow).  Try just:

> const char* array[];



Tue, 28 Oct 2003 23:10:38 GMT  
 problem with array of const pointers to const data
This problem occurs because const variables declared at file scope are static,
unless explicitly made extern:
extern const char* const array[] = { "abc", "def", "ghi" };


Wed, 29 Oct 2003 01:30:02 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. const pointer to const data problem

2. Array of const pointers to const variable.

3. Type Casting Const Pointers to non const pointers

4. Help: inline char const* const& max(char const* const &a, char const* const &b)

5. const pointer and const reference

6. const method and non-const pointer

7. multidimensional arrays of const data

8. const array of pointers to const data - Which compilers are correct?

9. const pointer to 2-D array of consts

10. Using const pointers to arrays

11. const arguments or const member methods

12. typedef int COMPARE(const void *, const void *);

 

 
Powered by phpBB® Forum Software