Code compiles properly with 'make', but shows error on XCode - xcode

My code compiles well with 'make.' However, when I attempt to do the same with Xcode, the code shows the following error:
"Invalid operands to binary expression ('const value_type' (aka 'const Vertex') and 'const value_type' (aka 'const Vertex'))"
I would be grateful if someone please point me towards a solution. I am currently using OSX 10.10.4 and Xcode 6.3.2. The corresponding screenshot is kept here:

The error message seems clear. You can't use == to compare these two objects. Research and discover another way to compare those object or amend the == operator so that it accepts the types you'd like to compare.
A search of similar error messages on SO yields a number of good answers including:
Invalid operands to binary expression

Just tried a simple solution. Deleted Xcode 6.3.2 and installed back Xcode 6.1.1. Everything now works fine. I have no idea though what has really happened here.

Related

Invalid Overloading boost::asio::io_service::run

I have been facing issues with using boost::asio::io_service::run in Linux, very very similar to this: creating a boost::asio worker thread with boost::thread under linux.
I see that the answer for that question is
"The error is be that boost::asio::io_service::run is overloaded, in which case you have to resolve the ambiguity."
Can someone tell me how does one resolve this ambiguity for it? Thanks.
I am in RHEL 7.7, coding using an Eclipse IDE. My Code segment is:
std::vector<boost::thread> threadPool;
boost::assio::io_service IOService;
.
.
threadPool.pushback(boost::thread(boost::bind(&boost::asio::io_service::run, &IOService)));
I get the error "Invalid overload of 'boost::asio::io_service::run' "
I see that boost::asio::io_service::run has two overloads:
std::​size_t boost::asio::io_service::run()
std::​size_t boost::asio::io_service::run(boost::system::error_code &ec)
I don't know how to resolve the ambiguity as they have the same return. If I try to add in a variable like this:
threadPool.pushback(boost::thread(boost::bind(&boost::asio::io_service::run(), &IOService)));
I get the error:
"Invalid Arguments 'Candidates are unsigned long int run()' "
and I don't know what to do.
Can someone teach a confused idiot like me what should i do? Is it an environment problem, a linking problem or a declaration problem?
EDIT 1: Using lambdas gives the error
'Address of overloaded function with no contextual type information'
which makes no sense and I assume is merely reiterating the ambiguity of the function.
This error does not show up in the Console window, which details the results of the Make, only in the Errors window. This makes me think it purely a IDE syntax check type error? GCC version is 4.8.5.

Warning in list initialization in C++11

This is my code :
int x=65;
char ch{x};
And this is the warning when compiled with `-std=C++11 flag:
Narrowed conversion from "int to char"
But I think there should be an error as x is not a constant and we are initializing ch with a non-constant value. What actually happens?
You're right that the standard treats this as an error, and allows implementations to flat out reject this code.
However, implementations are almost never required to reject code that does not conform to the standard. They have to diagnose the problem, but if they attach the label "warning" to it and continue to accept the code, there is no problem.
In this case, C++11 made perfectly well-formed C++03 code into an error (not entirely your code, but char ch[] = {x}; used to be valid), so compilers have a good reason to treat it as only a warning: they want to accept as much formerly valid code as reasonable, or users might have a good reason to switch to another compiler.
clang will give you an error:
main.cpp:23:9: error: non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list [-Wc++11-narrowing]
gcc as far as I remember decided to issue warning as there is too many source code that would be broken by such decision.
when you initialize variable using uniform initialization then narrowing conversions are forbidden.

Has casting (using as) in Swift changed recently (maybe in the latest beta)?

I've just gone back to a project I started ages ago and the compiler is throwing out hundreds of errors about objects not being convertible (to objects which subclass them), and suggesting I use as! instead of as, to force the cast.
Is this a bug in the latest X-Code beta, or has the down-casting syntax changed?
The syntax has changed for Swift 1.2. See Apple's blog post about it.
Here's a summary from their article:
Swift 1.2 separates the notions of guaranteed conversion and forced
conversion into two distinct operators. Guaranteed conversion is still
performed with the as operator, but forced conversion now uses the as!
operator. The ! is meant to indicate that the conversion may fail.
This way, you know at a glance which conversions may cause the program
to crash.

C++ Builder F1007 Irreducible Expression Tree

I'm using C++ builder XE under Windows 7 pro.
I'm currently stepping through a function and want to inspect the value of some of my variables. There's a character array I've got, local to a function.
char result[80];
When I try to inspect this (with the code paused inside this function), a message pops up :
Error inspecting 'result': F1007 Irreducible expression tree
If I try to add a watch to this variable, it says "???".
Any ideas what could cause this, and what it could mean in this context ?
According to the documentation:
F1007 Irreducible expression tree (C++)
An expression on the indicated line of the source file caused the code generator to be unable to generate code. Avoid using the expression. Notify Embarcadero if an expression consistently reproduces this error.
You are likely encountering a codegen bug and should file a Quality Central ticket to Embarcadero for review.

Getting error when trying to create vertices in cocos2d

I'm getting the error
Cannot Initialize a variable of type 'LineVertex*' (aka '_Line Vertex*) with an rvalue of type 'void*'
This is the line of code:
LineVertex *vertices = calloc(sizeof(LineVertex*), numberOfVertices);
This worked until I switched my class from .m to .mm and now it's throwing me that error and I don't know how to fix it. I am using Xcode 5 and the latest version of Cocos2D. I read that it might have something to do with casting but I honestly don't know how to do that, I couldn't get it to work correctly. Thank you so much in advance!
It should be like this.
LineVertex *vertices = static_cast<LineVertex *>(calloc(sizeof(LineVertex*), numberOfVertices));
For further information, please take a look at the FAQ.
Bjarne Stroustrup's C++ Style and Technique FAQ: Why must I use a cast to convert from void*?

Resources