Expected nested-name-specifier - c++

I am taking my project from my laptop to another and I encounter an error.
My project runs perfectly on my machine that I use codeblocks.
Now, I try to compile it with catkin and I get an expected nested-name-specifier before "XXX". A code snipet where this error occurs is the following
template <class T>
struct convert{
using to_int = int;
}
Outputs
expected nested-name-specifier before 'to_int'
using-decleration for non-member at class scope
expected ';' before '=' token
I get this error in multiple lines of the file and at first I thought that it was a compiler issue.
I then updated from gcc 4.6 to 4.8 using this thread as a guide but I still have the same issues. Is there a specific reason I get this error? If it's not a compiler issue what could it be?
Cheers,
Panos

Related

Compilation error: use of deleted function

I am working through some example code from Lazar and Penea, Mastreing Qt5:
https://github.com/PacktPublishing/Mastering-Qt-5
I think I am starting to understand the code, but I am stuck with a compilation error in the method "addAlbum" in the class "AlbumModel", The offending line is
unique_ptr<Album> newAlbum(new Album(album));
which yields the error message
error: use of deleted function ‘Album::Album(const Album&)’
unique_ptr<Album> newAlbum(new Album(album));
^
I am using CMake 3.10.2 and cpp 7.5.0. I presume the github code is correct, so this error is a bit puzzling. Although there are a lot of "use of deleted function" discussions here on stackoverflow, I have not been able to determine the cause of the error.

g++ error message "use 'this->equal' instead?"

I am trying to use stlplus ntree class and have written a program using it, and I have no problem compiling it in a Windows environment. I tried to port it into Ubuntu, but have errors.
stlplus ntree class uses template. Here is an example of my code
ntree<rule_node_struct> t;
ntree<rule_node_struct>::iterator cur_it;
if (cur_it == t.root())
{
// do something
}
When I compiled using g++, I get the following error message
In instantiation of ‘bool stlplus::ntree_iterator::operator==(const this_iterator&) const [with T = rule_node_struct; TRef = rule_node_struct&; TPtr = rule_node_struct*; stlplus::ntree_iterator::this_iterator = stlplus::ntree_iterator]’:
/usr/lib/stlplus3-03-08/containers/ntree.tpp:133:19: error: ‘equal’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
/usr/lib/stlplus3-03-08/containers/ntree.tpp:133:19: note: declarations in dependent base ‘stlplus::safe_iterator, stlplus::ntree_node >’ are not found by unqualified lookup
/usr/lib/stlplus3-03-08/containers/ntree.tpp:133:19: note: use ‘this->equal’ instead
Why does g++ has this error while Windows Visual Studio does not?
That seems to be a bug in the ntree class, as G++ does proper two-phase lookup of symbols, while VC seems to accept the broken code. Note that earlier versions of G++ also accepted this kind of code (AFAIK) and therefore it only got fixed in the latest version in the repository. Although that version is from 2010. It seems to me that it never made it into any release, so use the HEAD version or ask them to do a release.

How to include Accelerate framework with i686-apple-darwin11-llvm-g++-4.2?

I am trying to use the Accelerate framework on a small C++ program. I'm not even using XCode, only a simple Makefile.
The compiler complains when I add the following line to my code:
#include <Accelerate/Accelerate.h>
The error is the following:
In file included from /System/Library/Frameworks/vecLib.framework/Headers/vecLib.h:41,
from /System/Library/Frameworks/Accelerate.framework/Headers/Accelerate.h:20,
from Diana.cpp:20:
/System/Library/Frameworks/vecLib.framework/Headers/vDSP.h:9008: error: expected identifier before numeric constant
/System/Library/Frameworks/vecLib.framework/Headers/vDSP.h:9008: error: expected `}' before numeric constant
/System/Library/Frameworks/vecLib.framework/Headers/vDSP.h:9008: error: expected unqualified-id before numeric constant
/System/Library/Frameworks/vecLib.framework/Headers/vDSP.h:9028: error: expected declaration before ‘}’ token
The compiler I'm using is i686-apple-darwin11-llvm-g++-4.2, which is a gcc 4.2.1, and the line that I use to compile (not to link) is:
i686-apple-darwin11-llvm-g++-4.2 -D__MACOSX_CORE__ -c -o Diana.o Diana.cpp
Should I add some additional flag(s) when compiling this? I tried adding the "-framework Accelerate", but it doesn't change anything, since this should only be included in the linkage process (am I right?).
I googled some of these error messages and I didn't find anything.
I would really appreciate any help. Thank you!
PS: My OS X version is Lion 10.7.5, and XCode is 4.4.1.
I figured it out: I checked what was on line 9008 of vDSP.h and the problem was that I was declaring an FFT_FORWARD constant before including the Accelerate.h.
Fixed!

What can cause ambiguous symbol errors on one computer and not another?

I'm using Visual Studio 2010 to work on C++ code. The project and all its contents have been written by someone else, and copied onto a shared drive. When the creator builds it on his computer, it works fine. When I try to build the solution, I get a whole bunch of these errors
error C2872: '<lambda0>' : ambiguous symbol could be
'[File].cpp(66) : anonymous-namespace'::<lambda0>' or
'[Different file].h(549) : `anonymous-namespace'::<lambda0>'.
Here's an example of a line which is said to be in error:
std::pair<int, std::pair<int, Point>> b) -> bool { return (a.second.second < b.second.second ); });
It seems like the error always occurs with a line which ends in '});'. The full code is rather enormous to show here, and it works on other computers, so presumably it's a problem with my settings or something. Can anybody hazard a guess as to what they may be?
Not sure if you've seen this or not but according to MSDN page for that compiler error:
C2872 can occur if a header file includes a using Directive (C++), and a subsequent header file is #include'd and contains a type that is also in the namespace specified in the using directive. Specify a using directive only after all your header files are specified with #include.
MSDN Page
I have had the same issue withe ambiguous symbol problem. For me, it turns out that I was using two namespaces which have the same function but obviously different definitions. I have to stop using one of the namespaces and this solve the issue.
As an example:
using namespace cv;
using namespace boost::accumulator;
accumulator_set<double, stats<tag::mean, tag::variance> > acc;
double meanval = mean (acc);
This will through a compilation error: error C2872: 'mean' : ambiguous symbol This is because both namespaces cv and boost::accumulator have the same function "mean"
I hope this helps
I have had the same issue
Installing VS2010 SP1 fixed the ambiguous anonymous-namespace'::<lambda0> issue for me. VS2010 without the SP1 has problems with lambdas.

Really strange Eclipse error when attempting to Compile C++ code, looks like my code is never being deleted

I'm fairly new to c++ and decided to start learning by creating several basic projects. About halfway through I realized I was getting the same compiler errors when building my solutions, even though I was changing my code. I figured I had errors somewhere, so I decided to slowly undo until my errors went away. But, the same compiler errors were still there. I kept using undo until the only code that was left was:
#include <iostream>
These were the errors printed to my console:
../src/client.cpp:10:18: error: Note.h: No such file or directory
../src/client.cpp:12: error: 'bst' is not a namespace-name
../src/client.cpp:12: error: expected namespace-name before ';' token
../src/client.cpp: In function 'int main()':
../src/client.cpp:16: error: 'bst' has not been declared
../src/client.cpp:16: error: 'n' was not declared in this scope
The first error was due to a mispelling of "Node.h". I fixed the spelling mistake and the error persisted. But, I only have 1 line of code, and apparently line 16 contained an error.
HAS anybody ever had an issue like this before? I've been searching for a solution all night and havent had any luck. I'm running osx 10.6.8 (64bit) with a the newest 32bit version of eclipse. It started for no apparent reason. Thanks!!