0
私は2001年に書かれたプログラムをC++でコンパイルしようとしています。ターミナルでセットアップスクリプト(すなわち./setup
)を実行すると、以下のエラーが表示されます。私は解決策を探しましたが、私が得意とするのは、このタイプのエラーはgccのそれ以降のバージョン(バージョン4以上)によって生成されるということです。コンパイラがエラーを表示するコードを編集して、エラーなしで実行するにはどうすればよいですか。エラー:括弧で囲まれたtype-idの後に配列のバインド禁止があります
[email protected]:~$ cd Desktop/WebTraff/WebTraff && ./setup
Making executables in root directory
make: Nothing to be done for 'all'.
Making ProWGen
g++ -c -g stream.cc
stream.cc: In member function ‘unsigned int* RequestStream::GeneratePopularities()’:
stream.cc:104:39: error: array bound forbidden after parenthesized type-id
if ((popularity = new (unsigned int)[noofDistinctDocs]) == NULL)
^
stream.cc:104:39: note: try removing the parentheses around the type-id
stream.cc: In member function ‘unsigned int* RequestStream::GenerateFileSizes()’:
stream.cc:173:49: error: array bound forbidden after parenthesized type-id
unsigned int *filesizes = new (unsigned int)[noofDistinctDocs];
^
stream.cc:173:49: note: try removing the parentheses around the type-id
stream.cc: In member function ‘void RequestStream::GenerateUniqueDocs(Node*, int, Node*, int)’:
stream.cc:378:28: error: array bound forbidden after parenthesized type-id
uniqueDoc = new (Request*)[noofDistinctDocs];
^
stream.cc:378:28: note: try removing the parentheses around the type-id
Makefile:11: recipe for target 'stream.o' failed
make: *** [stream.o] Error 1
cp: cannot stat 'ProWGen': No such file or directory
Making CacheDriver
g++ -c CacheDriver.cc
g++ -c lru.cc
lru.cc: In constructor ‘Lru::Lru(unsigned int)’:
lru.cc:21:36: error: array bound forbidden after parenthesized type-id
if ((hash_table = new (LruNode*)[MAX_SIZE]) == NULL)
^
lru.cc:21:36: note: try removing the parentheses around the type-id
lru.cc:23:61: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
ErrorMessage("Not enough memory to allocate hash table");
^
lru.cc: In member function ‘LruNode* Lru::get_new_node(unsigned int, unsigned int)’:
lru.cc:143:59: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
ErrorMessage("Cannot allocate more memory for new nodes");
^
lru.cc: In member function ‘void Lru::found_update(LruNode*)’:
lru.cc:270:66: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
if((loc != head)&&(succloc == NULL)) ErrorMessage("\nright here");
^
Makefile:8: recipe for target 'CacheDriver' failed
make: *** [CacheDriver] Error 1
cp: cannot stat 'CacheDriver': No such file or directory
Making popularity
gcc -o popularity main.o getch.o gettoken.o hash.o -lm
Making lrustack and freqsize
make: Nothing to be done for 'all'.
私が正しく読んでいれば(必ずしもそうではありません - ここで就寝しています)、これはノースローの 'new'ではありませんが、' new 'あなたがノースローの' new'を使用している場合です。だから、これは実際には古い標準のC++セマンティクスを使ったコードです。 –
コンパイラを引用するには、 "type-idのまわりのかっこを削除してみてください"。 – molbdnilo