initializer element is not constant + extern

Question and Answers, Ask Question, Start Discussioninitializer element is not constant + extern
OldBluBear (Dave) asked 3 years ago

I am in the process of bringing up sccs; from old (K&R) code.  Have got as far as compiling the libPW,  all is well until I hit xalloc.c.  it throws the following error:
“xalloc.c:50:1: error: initializer element is not constant”

the relevant lines of code are code
49: extern end;
50: unsigned Lastbrk = (unsigned) &end;

Both end and Lastbrk are used in a number of cannot be moved to main

Since this is not my original code but taken from SunOs source  and must have passed QC  when it became part of the original code base. I am wondering if this is gcc being finicky  (I am compiling  with -w set to suppress it’s objection too various casts or lack of them in the code) I wish to make the minimum changes to the code. so a rewrite is out Looking at sccs from various source code of sccs, xalloc.c is the same in all of them!

Any suggestions as to valid fix please.

1 Answers
lynxbeedev Staff answered 1 year ago

Hi, please check “How to resolve: error: initializer element is not constant” post for the answer. Hope this helps.