Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am starting with boost hana, and I am currently getting this compile problem while writing a basic program:
#include <boost/hana/define_struct.hpp>
namespace hana = boost::hana;
struct Foo
{
BOOST_HANA_DEFINE_STRUCT(Foo,
(int, var1_),
(double, var2),
);
};
I am using latest gcc compiler (6.1) and the compiler error that I get is
boost/hana/detail/struct_macros.hpp:2462:103: error:
‘BOOST_HANA_PP_DROP_BACK’ does not name a type
This is weird because when I looked at the headers, boost/hana/detail/preprocessor.hpp (a file included by the above struct_macros.hpp) does include this macro definition.
EDIT: Macros are horrible. :( Take a look at first answer.
It should be:
struct Foo
{
BOOST_HANA_DEFINE_STRUCT(Foo,
(int, var1_),
(double, var2) // no comma
);
};
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I'm currently reading a c++ book and one of the function is
void fp(char v[]){
for(char* p = v; *p!=0;p++) use(*p);
}
I wrote this into my editor and compiled it. I also included the headers
#include <iostream>
#include <string.h>
But my terminal returns the following message:
use of undeclared identifier 'use'
I also google it and its nowhere to be found online, the function doesn't exist.
That's because there is no such standard library function.
The author is either using pseudo-code here, or has defined this function somewhere else in the book.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I keep getting the error "vector does not name type" from one of my classes each time I try to compile my code.
#ifndef DISK
#define DISK
#include "PageTableEntry.h"
#include <vector>
class disk{
private:
Vector <PageTableEntry*> frames;
public:
void addFrame(int Location, PageTableEntry* pte);
void removeFrame(int pteLocation);
Disk();
};
#endif
You should quote errors verbatim. I assume the error is actually more along the lines of Vector does not name type.
You have either not included the declaration for Vector in your code, doing so would provide the compiler with a type, or you have (more likely) mistakenly written Vector when it should be std::vector. Letter case and namespaces matter in C++.
Try:
std::vector<PageTableEntry*> frames;
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
Hi guys I am just starting to use C++ and I have a problem when I run this short code
#include <cmath>
#include <iostream>
int main()
{
std::cout << std::legendre(3, 0.25);
}
I get that std does not contain legendre, but I am fairly sure it is in cmath. Can someone give advice?
std::legendre was introduced in C++ since C++17. gcc compiles your code with no problem since version 7, clang since version 5 and MSVC since preview 2018 https://godbolt.org/z/reoiaD
You need to enable C++17 with -std=c++17 and possibly update your compiler.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
My code:
#include <vector>
std::vector<std::string> keyNamesList = { "A", "B" };
Won't compile, getting the error:
No matching constructor for initialization of std::vector<std::string>
Which is weird, because I am using C++11 (Xcode LLVM) and the line above it which does compile is a std::vector<int> = { 1, 2 };
This has to work. Any thoughts?
You also need to #include <string>.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I was practising using C++ templates (sounds way better than "playing around") by coding something that would basically be my own implementation of std::array when I stumbled across an odd compilation failure. I reduced the problem into the following class, which fails to compile on gcc version 4.9.0:
template <typename TestType>
class TestClass
{
TestType[10] data;
};
What am I doing wrong here?
The array part of the type should go after the identifier:
TestType data[10];