I was trying to understanding check list of warning/error thrown by cppcheck from https://sourceforge.net/p/cppcheck/wiki/ListOfChecks/
I come across following warning in auto section :-
suspicious assignment of pointer argument.
useless assignment of function argument.
what is meaning of these , Any help will be appreciated.
Thanks.
Related
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.
I used set_prolog_flag(stack_limit, 5000000000). in my code.
But then i got the following error:
ERROR: No permission to modify static procedure "set_prolog_flag/2"
It seem that i don't have persmission to modify stack_size.Is there a solution to this?
Emolai, it seems that you consulted info out of date.
You need to set the stack limits this way:
:- set_prolog_stack(stack, limit(5000000000)).
See the colon+minus? This signify that the goal set_prolog_stack/2 is to be executed and not defining a new clause set_prolog_stack/2. This explains the error you got.
You are now good to go. Is your question solved ?
I'm going through the book Programming for Artificial Intelligence by Ivan Bratko, I'm stuck on a basic problem and running into an error and the previous answers on stack overflow don't seem to be helping.
I'm stuck trying to write a rule using a previous fact as an argument and getting the error
Single variables: [Y]
the code I'm trying to run is this
parent(myfather,me).
parent(mymother,me).
happy(X) :-
parent(X,Y).
I've managed to make rules like this in the past and I think i'm just missing something very obvious as to why this isn't working. I think that when this compiles and I run
happy(myfather).
It will return true as it will replace X in the happy rule with myfather, then check parent(X,Y) with parent(myfather,Y). and try to then see if there is a fact that says parent(myfather,somethingelse....).
I'm also using swipl on macOS if that is relevant, thanks.
EDIT:
I hadn't checked but the program actaully works as it should but still gives the warning, it makes sense however is there any way of getting rid of the error or an understanding of why the error is there?
Singleton variables is a warning, not an error.
It is meant to remind you that you have a named variable occurring only once within a rule.
If you want to suppress the warning for that particular variable, rename it to a name beginning with underscore (e.g. _Y), e.g.:
happy(X) :- parent(X, _Y).
or rename it to _ (anonymous variable), e.g.:
happy(X) :- parent(X, _).
This type of warning is very useful for spotting typos, such a mistyped variable name:
happy(Child) :- parent(Chidl, Parent), happy(Parent).
Warning: Singleton variables: [Child,Chidl]
or other kind of typos, such as a period typed in place of a comma:
happy(Child) :- parent(Child, Parent). happy(Parent).
Warning: Singleton variables: [Parent]
Warning: Singleton variables: [Parent]
or other logical errors.
Without the singleton variable warning, these errors would go unnoticed and would be more difficult to track down.
So, seeing this warning usually rings a bell for looking for other type of errors as well. If there are no other errors, then just fix the singleton variable by making it anonymous.
If you know what you are doing, you can globally disable the warning with:
:- style_check(-singleton).
I know this is an old question, but i get the solution for that, if you got Singleton variables: [Y] error message, please check your code and your Queries is it mixed with upper-case, lower-case or not. Because Prolog is case sensitive.
I wanted to figure out the possibility to convert the following statement into terms (not relations) but without the warning of Singleton variables: PERSON while compiling.
Alex likes everyone who likes icecreams.
My following logic gets the Singleton Warning which I want it to remove. The code works fine though.
likes(alex,likes(Person,icecreams)).
The following gives you the same as your try without the warning :
likes(alex,likes(_,icecreams)).
I am trying to learn how to use the DrRacket debugger's annotate function. My ultimate aim is to build a REPL that you can execute from within a closure and have access to everything that's in scope. (see my previous question on that topic and Greg Hendershott's well-researched answer) For the time being, I'm just trying to explore how the annotate function works. You can see my first exploratory attempt at using it, and the results, here.
The error, which is happing inside of the annotator, seems to arise when it tries to match he application of string-append. The matcher is looking for a #%plain-app and the expanded syntax I'm presenting to it contains an #%app. I'm unsure if I should be expanding the syntax differently so it comes out as a #%plain-app or if there's something else I'm doing wrong to produce the syntax I'm feeding into the annotator. Does anybody see where my error is?
This revision to my previous pasterack post is swallowed without complaint. It seems that the syntax match must take place on a top-level syntax object (ruling out anything that could happen in an expansion phase, like a macro), and expansion must take place with a current namespace attached. There are some more subtleties in the syntax match, particularly around the fact that the syntax object needs to be free-identifier=? to #%plain-app. For all the gory details, refer to the mailing list thread I started.