Я скомпилировал свой код с указанным флагом -std=c++11
, и я получаю всевозможные ошибки, изображающие, что я должен использовать один и тот же флаг. Кроме того, auto
не распознается как тип.G ++, похоже, не распознает -std = C++ 11
Makefile:
GCCPATH = /path/gcc/5.3.0
CC = $(GCCPATH)/bin/g++
DARGS = -ggdb #debug arguments
CARGS = -std=c++11 #C arguments
WARGS = -Wall -Wextra #warning arguments
AARGS = $(DARGS) $(CARGS) $(WARGS) #all arguments
GCCLIBPATH = $(GCCPATH)/lib64
LIBS = -l curl
LIBD = -L $(GCCLIBPATH) -Wl,-rpath=$(GCCLIBPATH)
.PHONY: webspider
webspider: ../title/htmlstreamparser.o filesystem.o
$(CC) $(AARGS) -o [email protected] [email protected] $+ $(LIBS) $(LIBD)
filesystem:
$(CC) $(AARGS) -c [email protected]
Предупреждения и ошибки я получаю:
warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
error: ‘weblink’ does not name a type
for(auto weblink: weblinks)
Теперь мой вопрос: Что я должен сделать, чтобы сделать г ++ признать это ясно данный флаг?
Я также попытался заменить его -std=c++0x
, но безрезультатно.
EDIT:
Полный выход make
:
g++ -c -o filesystem.o filesystem.cpp
In file included from filesystem.cpp:1:0:
filesystem.hpp:23:36: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
std::string dir = getCurrentPath();
^
filesystem.cpp: In member function ‘std::__cxx11::string Filesystem::createMD5(std::__cxx11::string)’:
filesystem.cpp:49:19: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
for(long long c: result)
^
filesystem.cpp: In member function ‘void Filesystem::createLinkIndex(std::__cxx11::string, strVec)’:
filesystem.cpp:57:11: error: ‘weblink’ does not name a type
for(auto weblink: weblinks) {
^
filesystem.cpp:61:1: error: expected ‘;’ before ‘}’ token
}
^
filesystem.cpp:61:1: error: expected primary-expression before ‘}’ token
filesystem.cpp:61:1: error: expected ‘;’ before ‘}’ token
filesystem.cpp:61:1: error: expected primary-expression before ‘}’ token
filesystem.cpp:61:1: error: expected ‘)’ before ‘}’ token
filesystem.cpp:61:1: error: expected primary-expression before ‘}’ token
make: *** [filesystem.o] Error 1
Разве у вас нет 'CXXFLAGS = -std = C++ 11'? – NathanOliver
Вы видите, если флаг передан gcc и просто не распознан, или если на самом деле проблема с make-файлом? – Anedar
@NathanOliver Это было то, что я собирался сказать ... – callyalater