Given file foo.cc: const int arr[] = {0}; compiled to foo.o, and file bar.cc: extern const int arr[];
int main() { return arr[0]; } compiled and linked with foo.o, you get: s3:~/ootbc/personal/ivan$ g++ bar.cc foo.o /tmp/ccsMPoJa.o: In function `main': bar.cc:(.text+0x6): undefined reference to `arr' collect2: ld returned 1 exit status It works if the array isn't const. -- Summary: Extern doesn work for const arrays Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: igodard at pacbell dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44579