我在链接中编译项目:http://www.dis.uniroma1.it/challenge9/code/ch9-1.1.tar.gz 当我编译文件/解算器/ mlb-dimacs时,我遇到了错误。请帮帮我!
g++ -ansi -Wall -O6 -DNDEBUG -I../../lib -o sq.exe main.cc sp.cc smartq.cc parser_gr.cc timer.cc parser_ss.cc -lm
main.cc: In function ‘int main(int, char**)’:
main.cc:103:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:112:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc: In function ‘int parse_gr(long int*, long int*, Node**, Arc**, long int*, char*)’:
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
g++ -ansi -Wall -O6 -DNDEBUG -I../../lib -DMLB -DSINGLE_PAIR -o mbp.exe main.cc sp.cc smartq.cc parser_gr.cc timer.cc parser_p2p.cc -lm
main.cc: In function ‘int main(int, char**)’:
main.cc:103:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:105:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:112:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc: In function ‘int parse_gr(long int*, long int*, Node**, Arc**, long int*, char*)’:
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
g++ -ansi -Wall -O6 -DNDEBUG -I../../lib -DCHECKSUM -o sqC.exe main.cc sp.cc smartq.cc parser_gr.cc timer.cc parser_ss.cc -lm
main.cc: In function ‘int main(int, char**)’:
main.cc:103:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:112:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc: In function ‘int parse_gr(long int*, long int*, Node**, Arc**, long int*, char*)’:
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
g++ -ansi -Wall -O6 -DNDEBUG -I../../lib -DMLB -DCHECKSUM -DSINGLE_PAIR -o mbpC.exe main.cc sp.cc smartq.cc parser_gr.cc timer.cc parser_p2p.cc -lm
main.cc: In function ‘int main(int, char**)’:
main.cc:103:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:105:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:112:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc: In function ‘int parse_gr(long int*, long int*, Node**, Arc**, long int*, char*)’:
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
le@le-Extensa-4630:~/Desktop/ch9-1.1/solvers/mlb-dimacs$ make
g++ -ansi -Wall -O6 -DNDEBUG -I../../lib -o sq.exe main.cc sp.cc smartq.cc parser_gr.cc timer.cc parser_ss.cc -lm
main.cc: In function ‘int main(int, char**)’:
main.cc:105:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:114:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc: In function ‘int parse_gr(long int*, long int*, Node**, Arc**, long int*, char*)’:
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
g++ -ansi -Wall -O6 -DNDEBUG -I../../lib -DMLB -DSINGLE_PAIR -o mbp.exe main.cc sp.cc smartq.cc parser_gr.cc timer.cc parser_p2p.cc -lm
main.cc: In function ‘int main(int, char**)’:
main.cc:105:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:107:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:114:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc: In function ‘int parse_gr(long int*, long int*, Node**, Arc**, long int*, char*)’:
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
g++ -ansi -Wall -O6 -DNDEBUG -I../../lib -DCHECKSUM -o sqC.exe main.cc sp.cc smartq.cc parser_gr.cc timer.cc parser_ss.cc -lm
main.cc: In function ‘int main(int, char**)’:
main.cc:105:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:114:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc: In function ‘int parse_gr(long int*, long int*, Node**, Arc**, long int*, char*)’:
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
g++ -ansi -Wall -O6 -DNDEBUG -I../../lib -DMLB -DCHECKSUM -DSINGLE_PAIR -o mbpC.exe main.cc sp.cc smartq.cc parser_gr.cc timer.cc parser_p2p.cc -lm
main.cc: In function ‘int main(int, char**)’:
main.cc:105:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:107:18: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cc:114:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc: In function ‘int parse_gr(long int*, long int*, Node**, Arc**, long int*, char*)’:
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
parser_gr.cc:116:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
答案 0 :(得分:5)
在C ++中,字符串文字的类型为const char []
(请注意,这与C不同,因为历史原因,C字符串文字的类型为char []
。)
所以你应该改变
static char *err_message[] =
{
/* 0*/ "more than one problem line.",
/* 1*/ "wrong number of parameters in the problem line.",
到
static const char *err_message[] =
{
/* 0*/ "more than one problem line.",
/* 1*/ "wrong number of parameters in the problem line.",
在main.cc中,SZ_DIK_SMARTQ
是字符串文字,而szAlgorithm
的类型为char *
,您可以像这样使用const_cast
:
szAlgorithm = const_cast<char *>(SZ_DIK_SMARTQ);