I am trying to compile the program hull http://cm.bell-labs.com/netlib/voronoi/hull.html
This is quite a complicated program that involves several .c files
I get several warnings during compilation and the error:
hullmain.c:40: initializer element is not constant
This is the offending line:
FILE *INFILE, *OUTFILE, *DFILE = stderr, *TFILE;
It is part of many lines of stuff that occur before main()
hullmain.c includes hull.h, and in hull.h I find:
FILE* efopen(char *, char *);
extern FILE *DFILE;
I think the mysterious "initialize r element" error is related to
*DFILE = stderr
in hullmain.c
If I remove this bit I can get the program to compile (but it segfaults
when I run it :-)
What is the proper way to initialize the pointer *DFILE to be stderr?
If anyone can offer any tips on what is wrong and how to correct it,
I'd greatly appreciate it.
Thanks!
Bill 6 1475
johnnie...@tech ie.com wrote: I am trying to compile the program hull http://cm.bell-labs.com/netlib/voronoi/hull.html
This is quite a complicated program that involves several .c files
I get several warnings during compilation and the error: hullmain.c:40: initializer element is not constant
This is the offending line: FILE *INFILE, *OUTFILE, *DFILE = stderr, *TFILE;
It is part of many lines of stuff that occur before main()
hullmain.c includes hull.h, and in hull.h I find: FILE* efopen(char *, char *); extern FILE *DFILE;
I think the mysterious "initialize r element" error is related to *DFILE = stderr in hullmain.c
If I remove this bit I can get the program to compile (but it
segfaults when I run it :-)
What is the proper way to initialize the pointer *DFILE to be stderr?
If anyone can offer any tips on what is wrong and how to correct it, I'd greatly appreciate it.
Thanks! Bill
On some systems stderr is not a constant. The correct way to do this
would be to move the _initialization _ to main before DFILE is used.
Rob Gamble jo********@tech ie.com wrote: I am trying to compile the program hull http://cm.bell-labs.com/netlib/voronoi/hull.html
This is quite a complicated program that involves several .c files
I get several warnings during compilation and the error: hullmain.c:40: initializer element is not constant
This is the offending line: FILE *INFILE, *OUTFILE, *DFILE = stderr, *TFILE;
It is part of many lines of stuff that occur before main()
hullmain.c includes hull.h, and in hull.h I find: FILE* efopen(char *, char *); extern FILE *DFILE;
I think the mysterious "initialize r element" error is related to *DFILE = stderr in hullmain.c
You're right. The initializer for a file-scope variable
(or for a function-local `static' variable) must be a compile-
time constant, because it must produce its value before the
program actually starts running. All three `stdxxx' streams
are predefined by the implementation, but on some implementations
their definitions are not compile-time constants. Hence the
error.
If I remove this bit I can get the program to compile (but it segfaults when I run it :-)
At a guess, this is because the program tries to use DFILE,
expecting it to be a valid `FILE*' pointer -- but without an
initiazlizer, DFILE will be initialized to NULL ...
What is the proper way to initialize the pointer *DFILE to be stderr?
If anyone can offer any tips on what is wrong and how to correct it, I'd greatly appreciate it.
"Initialize " DFILE by assigning to it before it is used,
probably very early in main():
FILE *DFILE;
int main(...) {
DFILE = stderr;
...
}
An alternative approach would be to define DFILE as a macro
that expands to stderr:
/* FILE *DFILE = stderr; -- removed */
#define DFILE stderr
-- Er*********@sun .com
Eric Sosman wrote: jo********@tech ie.com wrote: I am trying to compile the program hull http://cm.bell-labs.com/netlib/voronoi/hull.html
This is quite a complicated program that involves several .c files
I get several warnings during compilation and the error: hullmain.c:40: initializer element is not constant
This is the offending line: FILE *INFILE, *OUTFILE, *DFILE = stderr, *TFILE;
It is part of many lines of stuff that occur before main()
hullmain.c includes hull.h, and in hull.h I find: FILE* efopen(char *, char *); extern FILE *DFILE;
I think the mysterious "initialize r element" error is related to *DFILE = stderr in hullmain.c
You're right. The initializer for a file-scope variable (or for a function-local `static' variable) must be a compile- time constant, because it must produce its value before the program actually starts running. All three `stdxxx' streams are predefined by the implementation, but on some implementations their definitions are not compile-time constants. Hence the error.
If I remove this bit I can get the program to compile (but it
segfaults when I run it :-)
At a guess, this is because the program tries to use DFILE, expecting it to be a valid `FILE*' pointer -- but without an initiazlizer, DFILE will be initialized to NULL ...
What is the proper way to initialize the pointer *DFILE to be
stderr? If anyone can offer any tips on what is wrong and how to correct
it, I'd greatly appreciate it.
"Initialize " DFILE by assigning to it before it is used, probably very early in main():
FILE *DFILE; int main(...) { DFILE = stderr; ... }
An alternative approach would be to define DFILE as a macro that expands to stderr:
/* FILE *DFILE = stderr; -- removed */ #define DFILE stderr
Of course if the program ever attempts to modify DFILE this would cause
a problem.
Rob Gamble jo********@tech ie.com wrote: I am trying to compile the program hull http://cm.bell-labs.com/netlib/voronoi/hull.html
This is quite a complicated program that involves several .c files
I get several warnings during compilation and the error: hullmain.c:40: initializer element is not constant
This is the offending line: FILE *INFILE, *OUTFILE, *DFILE = stderr, *TFILE;
It is part of many lines of stuff that occur before main()
hullmain.c includes hull.h, and in hull.h I find: FILE* efopen(char *, char *); extern FILE *DFILE;
I think the mysterious "initialize r element" error is related to *DFILE = stderr in hullmain.c
If I remove this bit I can get the program to compile (but it segfaults when I run it :-)
What is the proper way to initialize the pointer *DFILE to be stderr?
If anyone can offer any tips on what is wrong and how to correct it, I'd greatly appreciate it.
Thanks! Bill
Probably because we can't find stdio.h where stderr is '#define'ed.
--
Joe Wright mailto:jo****** **@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Joe Wright <jo********@com cast.net> writes: jo********@tech ie.com wrote: I am trying to compile the program hull http://cm.bell-labs.com/netlib/voronoi/hull.html This is quite a complicated program that involves several .c files I get several warnings during compilation and the error: hullmain.c:40: initializer element is not constant This is the offending line: FILE *INFILE, *OUTFILE, *DFILE = stderr, *TFILE;
[...] Probably because we can't find stdio.h where stderr is '#define'ed.
Doubtful. If <stdio.h> weren't included, the compiler would complain
that FILE and stderr are undeclared. (Actually, due to the way
typedefs are handled, it would probably get a parse error.)
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Thanks Eric, and everyone else who suggested this!
Now the program compiles properly. "Initialize " DFILE by assigning to it before it is used, probably very early in main():
FILE *DFILE; int main(...) { DFILE = stderr; ... }
Cheers
Bill This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gary Stephenson |
last post by:
I'm getting a clean generate, compile and link from my .pyx script, but when
I attempt to run the resultant .exe, I get:
"The procedure entry point Py_NoneStruct could not be located in the
dynamic link library python23.dll"
Can anybody provide me with a clue here? I've already cut down my script to
remove all references to None, Py_None, NULLs, etc, but to no avail. fwiw
I'm using latest Pyrex and ActiveState build 232.
|
by: Christopher M. Lusardi |
last post by:
Hello,
THE PROBLEM
-----------
If I compile parts of my program with CC, and C, using extern "C" as
appropriate it compiles without any errors, but it does a segmentation
fault when I run the program.
The variables involved in the segmentation fault are surrounded by
compiler directives. I am 100% sure that I do not have to extern "C"
|
by: Amadeus W. M. |
last post by:
I have a member static const int x defined in class Foo, and I'm passing
it by reference, and by value elsewhere (see the code below). Passing it
by value works, but by reference it doesn't: it thinks x is undefined.
Could someone explain what's going on here? Why can't I pass a static
const member by reference?
This is how I compile it:
g++ -g -Wall sample_main.C # g++ -v 4.0.1...
|
by: Webdiyer |
last post by:
I want to integrate SecurID two-factor authentication system of the
RSASecurity.inc into our asp.net application,but I get into trouble when
trying to call the API functions of the ACE Agent,I got an error message
saying "Cannot marshal parameter #2: Invalid managed/unmanaged type
combination (this value type must be paired with Struct)" when calling
"AceGetPinParams(iHandle,ref sd_pin)" function,here's my test code:
private static...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen. It is
almost like it is trying to implement it's own COM interfaces...
below is the header, and a link to the dll+code:
Zip file with header, example, and DLL:...
| |
by: ajikoe |
last post by:
Hi,
I tried to follow the example in swig homepage.
I found error which I don't understand.
I use bcc32, I already include directory where my python.h exist in
bcc32.cfg.
/* File : example.c */
#include <time.h>
|
by: Marco |
last post by:
Could anyone please tell me why the program has the following error? I
copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm
/////////////////////////////////////////////////////////////////////
#include <dos.h>
#include <string.h>
#include <stdio.h>
#define PORTADDRESS 0x378 /* Enter Your Port Address Here */
|
by: Rene |
last post by:
Hello to all!
For a long time I have been "fighting" a problem compiling an OpenGL
program which uses GLUT. First I have put a question in a Watcom group
(I want to use this compiler) to which I got no reply, in an OpenGL
group somebody recommended me to use Visual C++ which I did. That worked
OK but I do would like to use Watcom.
In the meantime I found solutions to several of the errors I got but one
is left which I cannot find a...
|
by: Jaco Naude |
last post by:
Hi,
I am running into a problem where I am trying to import C DLL into a
Visual C++ 2008 application. The functions in the C DLL are obviously
not name mangled (verified using Dependency Walker). When I try to use
any of the functions from the DLL, VC++ mangles these names (or so it
looks like) and complains that it can't link to mangled versions of
the function names. To avoid this I've figured that I need to declare
the functions I...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |