Nullptr was not declared in this scope

Nullptr was not declared in this scope

I am running Eclipse Helios and I have g++-4.6 installed. Hope I am not wrong that g++4.6 implements C++ 11 features. I have created a C++ project which uses the nullptr and auto keywords. The build gives the following errors:-

Actually it was building fine until yesterday. I am getting these from nowhere today. Please help me solve this problem.

7 Answers 7

To enable C++0x support, add the command-line parameter -std=c++0x to your g++ command line. Or, to enable GNU extensions in addition to C++0x extensions, add -std=gnu++0x to your g++ command line. GCC 4.7 and later support -std=c++11 and -std=gnu++11 as well.

Did you compile with -std=gnu++0x ?

Finally found out what to do. Added the -std=c++0x compiler argument under Project Properties -> C/C++ Build -> Settings -> GCC C++ Compiler -> Miscellaneous. It works now!

But how to add this flag by default for all C++ projects? Anybody?

Is that an actual compiler error or a Code Analysis error? Some times the code analysis can be a bit sketchy and report non-valid errors.

To turn off code analysis for the project, right click on your project in the Project Explorer, click on Properties, then go to the C/C++ General tab, then Code Analysis. Then click on "Use Project Settings" and disable the ones that you do not wish for.

Also, are you sure you are compiling with the C++11 compiler?

You are using g++ 4.6 version you must invoke the flag -std=c++0x to compile

Go to Settings -> Compiler. And add flag to "Have g++ follow the coming C++0x ISO C++ language standard [std=c++0x]

Читайте также:  Dynamic super resolution nvidia

Я использую C ++ 11 с использованием Qt Creator.

Это код, который работает в другом месте, соответствующая часть:

В чем может быть проблема?

Разве это уже не ключевое слово, не глобально ли это?

Решение

Открыть свой .pro файл изнутри QtCreator и добавить это

Comments

Copy link Quote reply

hipitt commented Feb 28, 2018

New clone, compilation failed.

OS: centos 7.3 1611

Faiss version:commit a280791 (HEAD -> master, origin/master, origin/HEAD)

Faiss compilation options: use example_makefiles/makefile.inc.Linux

step:
git clone .
cp example_makefiles/makefile.inc.Linux makefile.inc
make

g++ -o demos/demo_ivfpq_indexing -fPIC -m64 -Wall -g -O3 -mavx -msse4 -mpopcnt -fopenmp -Wno-sign-compare -fopenmp demos/demo_ivfpq_indexing.cpp libfaiss.a -g -fPIC -fopenmp /usr/lib64/libopenblas.so.0
In file included from demos/../IndexIVF.h:21:0,
from demos/../IndexIVFPQ.h:18,
from demos/demo_ivfpq_indexing.cpp:19:
demos/../Heap.h:190:9: warning: identifier ‘nullptr’ is a keyword in C++11 [-Wc++0x-compat]
const typename C::T * x = nullptr,
^
demos/../Heap.h:190:35: error: ‘nullptr’ was not declared in this scope
const typename C::T * x = nullptr,
^
demos/../Heap.h:191:38: error: ‘nullptr’ was not declared in this scope
const typename C::TI * > ^
demos/../Heap.h:215:23: error: ‘nullptr’ was not declared in this scope
const T * x = nullptr,
^
demos/../Heap.h:216:28: error: ‘nullptr’ was not declared in this scope
const long * > ^
demos/../Heap.h:228:24: error: ‘nullptr’ was not declared in this scope
const T * x = nullptr,
^
demos/../Heap.h:229:29: error: ‘nullptr’ was not declared in this scope
const long * > ^
demos/../Heap.h:385:52: error: ‘nullptr’ was not declared in this scope
size_t nj, const T *vin, const TI * > ^
In file included from demos/../IndexIVFPQ.h:18:0,
from demos/demo_ivfpq_indexing.cpp:19:
demos/../IndexIVF.h:82:19: error: ‘uint8_t’ does not name a type
virtual const uint8_t * get_codes (size_t list_no) const = 0;
^
demos/../IndexIVF.h:91:19: error: ‘uint8_t’ does not name a type
virtual const uint8_t * get_single_code (
^
demos/../IndexIVF.h:103:37: error: ‘uint8_t’ does not name a type
const uint8_t *code);
^
demos/../IndexIVF.h:103:46: error: ISO C++ forbids declaration of ‘code’ with no type [-fpermissive]
const uint8_t code);
^
demos/../IndexIVF.h:107:36: error: ‘uint8_t’ does not name a type
const > ^
demos/../IndexIVF.h:107:45: error: ISO C++ forbids declaration of ‘code’ with no type [-fpermissive]
const > ^
demos/../IndexIVF.h:110:48: error: ‘uint8_t’ does not name a type
idx_t id, const uint8_t *code);
^
demos/../IndexIVF.h:110:57: error: ISO C++ forbids declaration of ‘code’ with no type [-fpermissive]
idx_t id, const uint8_t *code);
^
demos/../IndexIVF.h:113:58: error: ‘uint8_t’ does not name a type
const > ^
demos/../IndexIVF.h:113:67: error: ISO C++ forbids declaration of ‘code’ with no type [-fpermissive]
const > ^
demos/../IndexIVF.h:124:31: error: ‘uint8_t’ was not declared in this scope
std::vector > codes; // binary codes, size nlist
^
demos/../IndexIVF.h:124:38: error: template argument 1 is invalid
std::vector > codes; // binary codes, size nlist
^
demos/../IndexIVF.h:124:38: error: template argument 2 is invalid
demos/../IndexIVF.h:124:40: error: template argument 1 is invalid
std::vector > codes; // binary codes, size nlist
^
demos/../IndexIVF.h:124:40: error: template argument 2 is invalid
demos/../IndexIVF.h:129:38: warning: overr > size_t list_size(size_t list_no) const override;
^
demos/../IndexIVF.h:130:11: error: ‘uint8_t’ does not name a type
const uint8_t * get_codes (size_t list_no) const override;
^
demos/../IndexIVF.h:131:44: warning: overr > const idx_t * get_ids (size_t list_no) const override;
^
demos/../IndexIVF.h:135:36: error: ‘uint8_t’ does not name a type
const idx_t
ids, const uint8_t code) override;
^
demos/../IndexIVF.h:135:45: error: ISO C++ forbids declaration of ‘code’ with no type [-fpermissive]
const idx_t
ids, const uint8_t code) override;
^
demos/../IndexIVF.h:135:49: warning: overr > const idx_t
ids, const uint8_t *code) override;
^
demos/../IndexIVF.h:138:50: error: ‘uint8_t’ does not name a type
const idx_t *ids, const uint8_t *code) override;
^
demos/../IndexIVF.h:138:59: error: ISO C++ forbids declaration of ‘code’ with no type [-fpermissive]
const idx_t *ids, const uint8_t *code) override

Читайте также:  Elder scrolls 5 skyrim карта

。。。。。。。。。。。。。。。。。
make: *** [demos/demo_ivfpq_indexing] Error 1

Ссылка на основную публикацию
Adblock detector