Re: Need key to solve the C++ problem
On Sep 27, 2:44 pm, kwan <kwan.ji...@gmail.com> wrote:
On Sep 27, 2:11 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
kwan wrote:
[..cannot compile..]
main.cc:8:19: label.h: No such file or directory
What part of this error message don't you understand?
Let's skip the rest of the same ones...
[..]
State.h:7:21: Vector2.h: No such file or directory
State.h:8:26: Vector2Array.h: No such file or directory
[..]
State.h:11: error: `Vector2' does not name a type
State.h:12: error: `Vector2Array' does not name a type
So, if it can't find certain headers, could it be that it
can't find the types *apparently defined* in those headers?
[..and so on..]
Come on, pay attention to what your compiler is telling you!
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
The main problem is that it is perhaps can not find the right path for
the header file, I wrote a small program but it compiles and runs
properly.
-------------------------
As notice, when I do the seek, and replace the full path inside the
soft code, it is not show the error.
I replaced <bool.h> with this
</usr/src/kernels/2.6.9-42.EL-smp-i686/include/config/isdn/capi/capifs/
bool.h
-----------
#include </usr/src/kernels/2.6.9-42.EL-smp-i686/include/config/isdn/
capi/capifs/bool.h>
//#include <trapfpe.h>
#include <stdlib.h>
#include <iostream.h>
#include <getopt.h>
#include <fstream.h>
#include <except.h>
#include <label.h>
#include "Problem.h"
#include "Evolution.h"
#ifndef NO_GUI
#include <GUI.h>
#include "Win.h"
#endif
static char *program_name = "evolve";
static bool batch = false;
static bool restart = false; // TODO: use this flag
void options(int argc, char **argv);
void evolve(void);
int
main(int argc, char **argv)
{
options(argc, argv);
//trapfpe();
#ifdef except_h_HAS_EXCEPTIONS
try {
#endif /* except_h_HAS_EXCEPTIONS */
evolve();
#ifdef except_h_HAS_EXCEPTIONS
}
catch (exception &e) {
cerr << "ERROR: " << program_name << ": " << e.what() << endl;
abort();
}
#endif /* except_h_HAS_EXCEPTIONS */
return 0;
}
void
evolve(void)
{
Problem problem(cin, cout);
Evolution evolution(problem, cout);
#ifdef NO_GUI
while (evolution.advance())
;
#else /* ! NO_GUI */
if (batch) {
while (evolution.advance())
;
}
else {
Win win(program_name, problem, evolution, cin, cout);
win.start_loop();
}
#endif /* NO_GUI */
}
#ifndef NO_GUI
static bool
hasopt(int argc, char * const *argv, const char *optstring, int opt)
{
int old_optind = optind;
int old_opterr = opterr;
optind = 1;
opterr = 0;
int has = false;
int c;
while ((c = getopt(argc, argv, optstring)) != -1)
if (c == opt) {
has = true;
break;
}
optind = old_optind;
opterr = old_opterr;
return has;
}
#endif /* NO_GUI */
void
options(int argc, char **argv)
{
const int BUFFER_SIZE = 63;
char buf[BUFFER_SIZE+1];
const char *optstring = "n:i:o:e:d:br";
static ifstream ifs;
static ofstream ofs;
static ofstream efs;
program_name = argv[0];
#ifndef NO_GUI
if (! hasopt(argc, argv, optstring, 'b'))
GUI::init(&argc, argv);
#endif
bool unrecognized = false;
int c;
while ((c = getopt(argc, argv, optstring)) != -1) {
switch (c) {
case 'n':
strncpy(buf, "in/", BUFFER_SIZE);
strncat(buf, optarg, BUFFER_SIZE);
ifs.open(buf);
if (ifs.bad()) {
cerr << program_name;
cerr << ": ERROR(options): ";
cerr << "cannot open input file 'in/"
<< optarg << "'" << endl;
exit(-1);
}
cin = ifs;
strncpy(buf, "out/", BUFFER_SIZE);
strncat(buf, optarg, BUFFER_SIZE);
ofs.open(buf);
if (ofs.bad()) {
cerr << program_name;
cerr << ": ERROR(options): ";
cerr << "cannot open output file 'out/"
<< optarg << "'" << endl;
exit(-1);
}
cout = ofs;
break;
case 'i':
ifs.open(optarg);
if (ifs.bad()) {
cerr << program_name;
cerr << ": ERROR(options): ";
cerr << "cannot open input file '"
<< optarg << "'" << endl;
exit(-1);
}
cin = ifs;
break;
case 'o':
ofs.open(optarg);
if (ofs.bad()) {
cerr << program_name;
cerr << ": ERROR(options): ";
cerr << "cannot open output file '"
<< optarg << "'" << endl;
exit(-1);
}
cout = ofs;
break;
case 'e':
efs.open(optarg);
if (efs.bad()) {
cerr << program_name;
cerr << ": ERROR(options): ";
cerr << "cannot open error file '"
<< optarg << "'" << endl;
exit(-1);
}
cerr = efs;
break;
case 'd':
label_debugging_level = atoi(optarg);
break;
case 'b':
batch = true;
break;
case 'r':
restart = true;
break;
case '?':
unrecognized = true;
break;
}
}
if (unrecognized || optind < argc) {
cerr << "usage: " << program_name;
cerr << " [-n name_of_run]";
cerr << " [-i input_file]";
cerr << " [-o output_file]";
cerr << " [-e error_file]";
cerr << " [-d debug_level]";
cerr << " [-batch]";
cerr << " [-restart]";
cerr << "\n";
exit(-1);
}
}