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

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.

Related

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.

prolog sort/4 undefined procedure built in

I am trying to use a supposedly built in procedure in SWI-Prolog.
The procedure in question is sort/4.
The thing is, when I try to use it in my program I get the following error:
ERROR: Undefined procedure: sort/4
ERROR: However, there are definitions for:
ERROR: msort/2
ERROR: sort/2
I don't understand because the documentation says its built-in, but Prolog doesn't know it. I really need to use this procedure
Would you know how to fix this issue ? I thought it was a matter of library and tried to add ":- use_module(library(lists))." at the beginning of my code but the situation remains the same.
Hope you can help me, have a good day
The sort/4 predicate as documented here is relatively new. If you get the latest stable or development version of SWI-Prolog it should be available. It is a built-in, not a part of a library.

Code compiles properly with 'make', but shows error on 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.

MinGW's gcc reports error where Cygwin's accepts

MingGW's gcc (4.8.1) reports the following error (and more to come) when I try to compile Expstack.c:
parser.h:168:20: error: field '__p__environ' declared as a function
struct term *environ;
where 'environ' is declared inside 'struct term{ ... }'. In unistd.h you find
char **environ
but nowhere a '__p__environ'.
Some other fields are declared likewise, but are accepted. Subsequent errors related to environ are reported as follows
Expstack.c:1170:38: error: expected identifier before '(' token
case Term_src: return e->item.src->environ;
^
Cygwin's gcc (4.8.3) accepts these constructs and has done so over various versions since
2006 at least, and gcc with various versions of Linux before that.
The source text uses CRLF despite my attempts to convert to DOS, and this is my only guess for an explanation.
I'll appreciate clues or ideas to fix the problem, but renaming the field is not especially attractive and ought to be totally irrelevant.
This is very unlikely to have to do with CR/LF.
The name ought to be irrelevant but it isn't: this one relates to the Windows integration that MinGW does and Cygwin does not, as alluded to in http://sourceforge.net/p/mingw/mailman/message/14901207/ (that person is trying to use an extern environ that it expects to be defined by the system. Clearly, the fashion in which MinGW developers have made this variable available breaks the use of the name as a struct member).
You should report this as a MinGW bug. Unpleasant as it may be, in the interim, renaming the member is the simplest workaround. It is possible that a well-placed #undef environ might help, but no guarantees.

How to view the result of an expression in MSVS2013?

I remember seeing somewhere that you can specify which dll to get the address of symbols so that one can use that variable in the watch window. I can't for the life of me remember where I saw this. The best that I can come up with is Format Specifiers in C++.
The reason I want this is so that I can see the visibility status of a window and MSVS keeps saying that identifier "IsWindowVisible" is undefined.
I was trying to use something like the following in the watch window:
::IsWindowVisible(m_hWnd),user32.dll
Using:
this->IsWindowVisible()
results in Function CWnd::IsWindowVisible has no address, possibly due to compiler optimizations. which is why I'm trying to use the win32 call. Ideas?
http://msdn.microsoft.com/en-nz/library/y2t7ahxk.aspx
Haven't tried it, but it seems to me that IsWindowVisible(m_hWnd) should work, or maybe IsWindowVisible(this->m_hWnd).

Resources