问题描述
- g++4.8编译不了auto,已加-std=c++11
-
ubuntu14.04, 64位, gcc 4.8 g++4.8已装文件server_main.cpp_中
int stringToInt(const std::string& str) { for(auto s : str) { if(!isdigit(s)) { std::cout<<"illegal number"; exit(-1); } } ... }
makefile里代码如下:
server_objects = m_socket.o serverSocket.o server_main.o client_objects = m_socket.o clientSocket.o client_main.o all : server client server: $(server_objects) g++ -Wall -std=c++11 -o server $(server_objects) client: $(client_objects) g++ -Wall -std=c++11 -o client $(client_objects) m_socket: m_socket.cpp g++ -std=c++11 -Wall -o m_socket m_socket.cpp serverSocket: serverSocket.cpp g++ -std=c++11 -Wall -o serverSocket serverSocket.cpp clientSocket: clientSocket.cpp g++ -std=c++11 -Wall -o clientSocket clientSocket.cpp **server_main: server_main.cpp g++ -std=c++11 -Wall -o server_main server_main.cpp ** client_main: client_main.cpp g++ -std=c++11 -Wall -o server_main server_main.cpp clean: rm -f *.o server client
执行make后
解决方案
g++ 4.8有点老,用5.x版本的吧。
解决方案二:
换gcc6。用最新版本。支持c++14了
时间: 2024-09-12 22:44:54