Summary
New clone, compilation failed.
Platform
OS: centos 7.3 1611
Faiss version:commit a280791 (HEAD -> master, origin/master, origin/HEAD)
Faiss compilation options: use example_makefiles/makefile.inc.Linux
Running on :
- [ v] CPU
- GPU
Reproduction instructions
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 * ids = nullptr,
^
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 * ids = nullptr,
^
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 * ids = nullptr,
^
demos/../Heap.h:385:52: error: ‘nullptr’ was not declared in this scope
size_t nj, const T *vin, const TI *id_in = nullptr,
^
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 idx_t ids, const uint8_t code) = 0;
^
demos/../IndexIVF.h:107:45: error: ISO C++ forbids declaration of ‘code’ with no type [-fpermissive]
const idx_t ids, const uint8_t *code) = 0;
^
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 idx_t *ids, const uint8_t *code) = 0;
^
demos/../IndexIVF.h:113:67: error: ISO C++ forbids declaration of ‘code’ with no type [-fpermissive]
const idx_t *ids, const uint8_t code) = 0;
^
demos/../IndexIVF.h:124:31: error: ‘uint8_t’ was not declared in this scope
std::vector < std::vector<uint8_t> > codes; // binary codes, size nlist
^
demos/../IndexIVF.h:124:38: error: template argument 1 is invalid
std::vector < std::vector<uint8_t> > 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 < std::vector<uint8_t> > codes; // binary codes, size nlist
^
demos/../IndexIVF.h:124:40: error: template argument 2 is invalid
demos/../IndexIVF.h:129:38: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 [enabled by default]
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: override controls (override/final) only available with -std=c++11 or -std=gnu++11 [enabled by default]
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: override controls (override/final) only available with -std=c++11 or -std=gnu++11 [enabled by default]
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
。。。。。。。。。。。。。。。。。
make: *** [demos/demo_ivfpq_indexing] Error 1
- Forum
- General C++ Programming
- ‘nullptr’ was not declared in this scope
‘nullptr’ was not declared in this scope
I am using JGrasp as IDE. I have confirmed by «Actual command sent» that the compiler being used is TDM-GCC-64bing++.exe, and I have confirmed that the edition of g++ is 4.8.1, which should recognize the ‘nullptr’ keyword along with most of C++11. I have ‘-std=c++11’ in the args for the compiler and linker. Having confirmed all of this multiple times, I cannot understand what is causing the error:
‘nullptr’ was not declared in this scope
nullptr is a C++11 keyword. On GCC 4.8, you need to switch on C++11 support with -std=c++11
kbw wrote: |
---|
On GCC 4.8, you need to switch on C++11 support with -std=c++11 |
ath2441 wrote: |
---|
I have ‘-std=c++11’ in the args for the compiler and linker |
could you post your source code? maybe you are making an error somewhere else, which is resulting in it not recognizing nullptr
#include <iostream>
using namespace std;
class Person
{
private:
string name;
public:
Person(){}
Person(string theName)
{
name = theName;
}
Person(Person& other)
{
if (other != nullptr)
name = other.name;
}
};
You could always just do if(other)
though person other isn’t a pointer anyways so not sure exactly what you are trying to do.
Last edited on
The variable other is a reference and my understanding is that references are pointers internally.
Using if(other) produces the error: «could not convert ‘other’ from ‘Person’ to ‘bool'».
Yeah I typed that then realized it wasn’t a pointer. You could always just pass as a pointer and do it the way you are now. Or maybe change the if statement to something like if(!other.name.empty())
Last edited on
Now that I think of this, I understand why my code was incorrect. The variable other is a reference to an object and probing whether it is null is unnecessary because null references are illegal. The compiler error was very misleading.
Last edited on
I learned why the compiler error was so misleading. ‘-std=c++11’ was in ARGS2 of the JGrasp compiler settings when it should have been in ARGS1.
Topic archived. No new replies allowed.
fisenkdima
Гость |
Хочу использовать в коде ключевое слово nullptr. При компиляции QtCreator выдаёт ругань вида: предупреждение: identifier ‘nullptr’ will become a keyword in C++0x [-Wc++0x-compat] |
||
|
mutineer
Гость |
Ключик для включения нового синтаксиса прописан в .pro ? |
||
|
fisenkdima
Гость |
Очевидно, нет. Я увидел, что nullptr подсвечен и успокоился. Т.е. QtCreator его по умолчанию знает, а компилятор (или какая сущность ругается на это ключевое слово) — нет? |
||
|
mutineer
Гость |
QMAKE_CXXFLAGS += -std=c++0x |
||
|
fisenkdima
Гость |
Гранд мерси. |
||
|
alex312
Хакер Сообщений: 606
|
QMAKE_CXXFLAGS += -std=c++0x Лучше — CONFIG += c++11 |
||
|
Alex Custov |
Ведь с Qt 5.0 есть дефолтная поддержка C++11. Или я не прав? Qt — это просто библиотека. Creator использует компилятор, которому нужно указать версию стандарта, как уже показали выше. |
||
|