Hi. have this code and compiler problem. GCC 2.95.3, BeOS, error
"initializer element is not constant"
[ ... 3000 + lines deleted for brevity ... ]
#ifdef FILEIO
{ static struct {
char *sfn;
FILE *sfd;
} stdfiles[] = {
{"STDIN", stdin},
{"STDOUT", stdout},
{"STDERR", stderr}
};
int i;
dictword *dw;
for (i = 0; i < ELEMENTS(stdfiles); i++) {
if ((dw = atl_vardef(stdfiles[i].sfn,
2 * sizeof(stackitem))) != NULL) {
stackitem *si = atl_body(dw);
*si++ = FileSent;
*si = (stackitem) stdfiles[i].sfd;
}
}
}
[ ... to end of source file deleted for brevity ... ]
------------
and this compiler problem...
[beos@dualP2 ~/forth/atlast-1.0] $ make
cc -O -DMEMSTAT -DALIGNMENT -DEXPORT -c atlast.c -o atlast.o
atlast.c: In function `atl_init':
atlast.c:3247: initializer element is not constant
atlast.c:3247: (near initialization for `stdfiles[0].sfd')
atlast.c:3248: initializer element is not constant
atlast.c:3248: (near initialization for `stdfiles[1].sfd')
atlast.c:3249: initializer element is not constant
atlast.c:3249: (near initialization for `stdfiles[2].sfd')
make: *** [atlast.o] Error 1
I see the property list being built, and shouldnt the FILE* defined as
an element of each pair be enough to allow stdin, stdout and stderr
to be assigned? This is not my code, a package I'm porting. How
to get this to compile would be greatly appreciated, email me directly
please, I'm too ashamed to speak again here publically about this :)
Thank you! 2 19511
Todd Nathan wrote: Hi. have this code and compiler problem. GCC 2.95.3, BeOS, error "initializer element is not constant"
[ ... 3000 + lines deleted for brevity ... ]
#ifdef FILEIO { static struct { char *sfn; FILE *sfd; } stdfiles[] = { {"STDIN", stdin}, {"STDOUT", stdout}, {"STDERR", stderr} }; int i; dictword *dw;
for (i = 0; i < ELEMENTS(stdfiles); i++) { if ((dw = atl_vardef(stdfiles[i].sfn, 2 * sizeof(stackitem))) != NULL) { stackitem *si = atl_body(dw); *si++ = FileSent; *si = (stackitem) stdfiles[i].sfd; } } }
[ ... to end of source file deleted for brevity ... ]
------------
and this compiler problem...
[beos@dualP2 ~/forth/atlast-1.0] $ make cc -O -DMEMSTAT -DALIGNMENT -DEXPORT -c atlast.c -o atlast.o atlast.c: In function `atl_init': atlast.c:3247: initializer element is not constant atlast.c:3247: (near initialization for `stdfiles[0].sfd') atlast.c:3248: initializer element is not constant atlast.c:3248: (near initialization for `stdfiles[1].sfd') atlast.c:3249: initializer element is not constant atlast.c:3249: (near initialization for `stdfiles[2].sfd') make: *** [atlast.o] Error 1
I see the property list being built, and shouldnt the FILE* defined as an element of each pair be enough to allow stdin, stdout and stderr to be assigned? This is not my code, a package I'm porting. How to get this to compile would be greatly appreciated, email me directly please, I'm too ashamed to speak again here publically about this :)
By the standard, none of stdin, stdout or stderr need necessarily be
constants -- though they are in many implementations.
HTH,
--ag
--
Artie Gold -- Austin, Texas
Todd Nathan <bi***********@yahoo.com> wrote: Hi. have this code and compiler problem. GCC 2.95.3, BeOS, error "initializer element is not constant"
[ ... 3000 + lines deleted for brevity ... ]
#ifdef FILEIO { static struct { char *sfn; FILE *sfd; } stdfiles[] = { {"STDIN", stdin}, {"STDOUT", stdout}, {"STDERR", stderr}
stdin, stdout and stderr aren't guaranteed to be compile time constants
- and you need compile time constants for aggregate initialisers.
So - the code should be written this way (this will work anywhere, so
should be fixed in the original codebase too):
{ static struct {
char *sfn;
FILE *sfd;
} stdfiles[] = {
{"STDIN", NULL },
{"STDOUT", NULL },
{"STDERR", NULL }
};
int i;
dictword *dw;
stdfiles[0].sfd = stdin;
stdfiles[1].sfd = stdout;
stdfiles[2].sfd = stderr;
/* ... */
[...] How to get this to compile would be greatly appreciated, email me directly please, I'm too ashamed to speak again here publically about this :)
Sorry, post here, read here - consider the next guy who comes along with
the same problem.
- Kevin. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Player |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello all.
I am in the process of teaching myself C# and I think I am doing OK.
I have learnt how to how to call the right constructor of a...
|
by: emin.martinian |
last post by:
When trying to compile python extensions written in C using "python
setup.py build" on cygwin I get the following error:
foo.c: initializer element is not constant
foo.c: error: (near...
|
by: tankbattle |
last post by:
That is, what's the difference between
<complexType name="Address" final="restriction">
<sequence>
<element name="name" type="string"/>
<element name="street" type="string"/>
<element...
|
by: montzter |
last post by:
Hi,
Got some declarations below but when I compiled it I got the above mentioned error.
1. I'd like to know if my implementation or stucture is doable.
2. How could i fix the problem...?...
|
by: jaime |
last post by:
Hi again all.
Given the line:
const int x=5;
Can I then use "x" as a constant expression? (By "constant expression", I
mean "constant expression" as defined in the C99 standard)
I've been...
|
by: hankypan1 |
last post by:
Hi All,
I need a tree data structure for my application. It is the non -
cyclic
simple tree where i can have any number of children node and each
child can recursively become a sub tree like a...
|
by: bobg.hahc |
last post by:
running access 2k;
And before anything else is said - "Yes, Virginia, I know you can NOT
use a variable to set a constant (that's why it's constant)".
BUT - my problem is - I want a constant,...
|
by: blackrunner |
last post by:
ERROR in my Query?!
ERROR:
Element GESCHLECHT is undefined in FORM.
i think everything ok. Maby somebody can help me here
Element GESCHLECHT is undefined in FORM.
The error occurred...
|
by: zoeb |
last post by:
Hi,
I am declaring an array which carries x coordinates, however these will vary depending on the geometry the user enters.
I have set my code up as follows, but get the "initializer element...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |