Error code E0065 & E0169 where there shouldnt be - c++

I am going along making my csgo cheat via C++. Everything is going well, until I get to the menu, which throws what appears to be false error messages.
Ive tried doing what visual studios "quick fixes" are. It puts a Semi-colon at the end of "ImGuiWindowFlags_NoTitleBar" and changes the first error to a E0169 as well.
void Menu::Render()
{
ImGui::GetIO().MouseDrawCursor = _visible;
if (!_visible)
return;
const auto sidebar_size = get_sidebar_size();
static int active_sidebar_tab = 0;
//ImGui::PushStyle(_style);
ImGui::SetNextWindowPos(ImVec2{ 0, 0 }, ImGuiSetCond_Once);
ImGui::SetNextWindowSize(ImVec2{ 1000, 400 }, ImGuiSetCond_Once);
// https://github.com/spirthack/CSGOSimple/issues/63
// quick fix
if (ImGui::Begin("testbuild"))
& _visible,
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar)) { <line 376
//auto& style = ImGui::GetStyle();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
{
ImGui::BeginGroupBox("##sidebar", sidebar_size);
{
//ImGui::GetCurrentWindow()->Flags &= ~ImGuiWindowFlags_ShowBorders;
render_tabs(sidebar_tabs, active_sidebar_tab, get_sidebar_item_width(), get_sidebar_item_height(), false);
}
ImGui::EndGroupBox();
}
ImGui::PopStyleVar();
ImGui::SameLine();
// Make the body the same vertical size as the sidebar
// except for the width, which we will set to auto
auto size = ImVec2{ 0.0f, sidebar_size.y };
ImGui::BeginGroupBox("##body", size);
if (active_sidebar_tab == TAB_ESP) {
RenderEspTab();
}
else if (active_sidebar_tab == TAB_AIMBOT) {
RenderEmptyTab();
}
else if (active_sidebar_tab == TAB_MISC) {
RenderMiscTab();
}
else if (active_sidebar_tab == TAB_CONFIG) {
RenderConfigTab();
}
ImGui::EndGroupBox();
ImGui::TextColored(ImVec4{ 0.0f, 0.5f, 0.0f, 1.0f }, "FPS: %03d", get_fps());
ImGui::SameLine(ImGui::GetWindowWidth() - 150 - ImGui::GetStyle().WindowPadding.x);
if (ImGui::Button("Unload", ImVec2{ 150, 25 })) {
g_Unload = true;
}
ImGui::End();
}
} <line 418
I expected everything to go away, but it didnt. Error messages:
Error (active) E0065 expected a ';' CSGOSimple 376
Error (active) E0169 expected a declaration CSGOSimple 418

The problem is this line right here:
if (ImGui::Begin("testbuild"))
The last parenthesis at the end closes the if statement. That means it expects the next thing to be some statement. An example of something it would expect:
if(ImGui::Begin("testbuild"))
return; // Notice we need a semicolon here because return is a statement
This is because if statements in C++ can have a statement or a block following it. Since you don't have a semicolon here (because you clearly don't mean for the if statement to end that early) it throws an error.
To fix this, you will need to remove that parenthesis and fix your if statement. It's not completely apparent to me what you actually intend to do here, so you will have to figure that out yourself. But at least you now have an idea of what's happening here.

Related

Get abending line number in C++ using Visual Studio

Okay, I've been beating my head against a brick wall for a couple of days now...
I have a __try __except piece of code with this in it:
__except(ExFilter(GetExceptionCode(),GetExceptionInformation())){
// Print the message ExFilter set up
MessageBox(NULL, (LPTSTR)outline, "setup/LoadSettingsFromIni error", MB_OK);
if(ExFilter_rc > 0) { // should we abend?
exit(9) ; // yes
}
} // end of __except...
and in the ExFilter code:
LONG ExFilter(DWORD error,LPEXCEPTION_POINTERS lpExceptionInfo){
void *addressPtr;
EXCEPTION_RECORD *myExecptionRecord;
myExecptionRecord = lpExceptionInfo->ExceptionRecord;
addressPtr = myExecptionRecord->ExceptionAddress;
At this point, addressPtr points to:
0x00007ff73b70d4c8 {Regshot-x64-ANSI-dbg.exe!LoadSettingsFromIni(HWND__ * hDlg), Line 355}
More of the code gets the program name using "GetModuleFileName" etc.
But I already know the program name.
I've tried many ways to get the data "Line 355" but no luck.
How do I get at it so I can put it in a message?
Thanks.
I'm sure many people have found a way around this, but here is my "poor man's solution" for trapping errors I suddenly thought of the other day:
I added a counter to areas in my code that might cause a problem, and then in the __except filter added code to show the counter, which would give me a more concise area to look at.
Here is what I did:
char outline[1310] ; // __except output line
size_t rc2 ; // lth of outline
int ctr ;
__try {
code
..
ctr = 1 ;
code
..
ctr = 2 ;
code
..
ctr = 3 ;
code
..
} // end of try
__except(ExFilter(GetExceptionCode(),GetExceptionInformation())){
// Print the message ExFilter set up
MessageBox(NULL, (LPTSTR)outline, "setup/LoadSettingsFromIni error", MB_OK);
if(ExFilter_rc > 0) { // should we abend?
exit(9) ; // yes
}
} // end of __except...
and in the ExFilter code:
LONG ExFilter(DWORD error,LPEXCEPTION_POINTERS
lpExceptionInfo){
void *addressPtr;
EXCEPTION_RECORD *myExecptionRecord;
myExecptionRecord = lpExceptionInfo->ExceptionRecord;
addressPtr = myExecptionRecord->ExceptionAddress;
sprintf(outline, ""); // blank outline
rc2 = strlen(outline);
rc = error ; // GetExceptionCode() passed by __except
if (rc == EXCEPTION_INT_DIVIDE_BY_ZERO) {
sprintf(outline+rc2, "Divide by Zero!");
goto f_end7a ; // continue
}
... more code for each trapped error.....
f_end7a: ;
rc2 = strlen(outline);
sprintf(outline+rc2, "\n\nError occured after instruction \"ctr = %i ;\" \n", ctr);
return EXCEPTION_EXECUTE_HANDLER; // return to __except...
So if an error occurs, a message is displayed, with a line like:
Error occurred after instruction "ctr = 2"
and I know approximately where it happened, between ctr = 2 and ctr = 3.
This may be "Mickey Mouse", but it's better than nothing.

result of call warning - want to use the result?

I have some difficulties with the new Swift 3.0. First I know the “result of call is unused” warning has been debated a few times already. I have read the topics in question and usually the suggested answer is to use #discardableResult or using _ = before the function. But in my case this isn’t working. Before upgrading xCode the code worked great. I tested it on my iPad and everything was ok. But then once I upgraded xCode and had to convert the code to comply with Swift 3.0 the problem appeared.
The thing is that whatever I do, the object in the game isn’t showing as it should. Like I said, previously it worked, but now it doesn’t anymore. When the character runs into the object and it crashes it, the game should display a crashed object, but instead it shows an image with a red “X” as if the image isn’t there.
Here is the code. I would appreciate any suggestion you guys have. Thanks in advance
for block in Blocks
{
block.move()
block.isColB()
if(block.manager.HasFloorL2)
{
if(block.isOnL2())
{
if(block.manager.FloorL2Obstact)
{
block.ObsColL2() // here, result of call to ObscColL2() is unused
}
break;
}
}
if(block.manager.HasFloorL1)
{
if(block.isOnL1())
{
if(block.manager.FloorL1Obstact)
{
block.ObsColL1() // here, result of call to ObscColL1() is unused
}
break;
}
}
}
Here is the function it refers to.
func ObsColL1() -> Bool
{
if(kong.Node.position.x+kong.Node.size.width*0.7 > self.holder.position.x+ObstacleL1.Node.position.x
&& kong.Node.position.x+kong.Node.size.width*0.7 < self.holder.position.x+ObstacleL1.Node.position.x+ObstacleL1.Node.size.width*0.3)
{
if(kong.Y() <= self.holder.position.y+(ObstacleL1.Node.position.y)+ObstacleL1.Node.size.height*0.7 && kong.Y() >= self.holder.position.y+ObstacleL1.Node.position.y)
{
if(kong.state != heroStates.flash && !self.ObstacleL1.crashed)
{
kong.Node.position.x = self.holder.position.x+ObstacleL1.Node.position.x-(kong.Node.size.width*0.55)
kong.Node.run(SKAction.moveTo(y: self.holder.position.y+ObstacleL1.Node.position.y+ObstacleL1.Node.size.height/2, duration: 0.5))
kong.die()
}
else
{
ObstacleL1.crash()
return true
}
}
}
return false
}
EDIT:
before and after
before and after
before and after 2

How to put Return Statement into block using clang

I'm trying to parse C files and add debugs at exit points of the functions using clang.
I can add debugs just before return, or exit of function using following code
if (isa<ReturnStmt>(s)) {
ReturnStmt *ReturnStatement = cast<ReturnStmt>(s);
TheRewriter.InsertText(ReturnStatement->getLocStart(), "{printf(\"[%s:%d] OUT \\n\", __FUNCTION__, __LINE__);\n", true, true);
}
But it doesn't work for functions like this:
//before preprocessing
int foo(int a)
{
if(a)
return 1;
else
return a;
}
//after
int foo(int a)
{
if(a)
{printf("[%s:%d] OUT \n", __FUNCTION__, __LINE__);
return 1;
else
{printf("[%s:%d] OUT \n", __FUNCTION__, __LINE__);
return a;
}
Unfortunately, simple getLocEnd doesn't work.
TheRewriter.InsertText(ReturnStatement->getLocEnd(), "}", true, true);
it puts "}" just after "return".
if(a)
{printf("[%s:%d] OUT \n", __FUNCTION__, __LINE__);
return }1;
Please, help me to detect end of Return Statement location, to put closing "}" or maybe it's less difficult to put ReturnStatement into some Compound Statement or so.
I also tried find end of Return Statement like this:
ReturnStatement->getLocStart().getLocWithOffset(strlen(retvalue) + 1);
but I can get return value in a string view only for ImplicitCastExpr.
Thanks.
It's a known bug with no simple solution.
here we have an answer. I found it here:
https://github.com/loarabia/Clang-tutorial/blob/master/CIrewriter.cpp
all you need is :
// Note Stmt::getLocEnd() returns the source location prior to the
// token at the end of the line. For instance, for:
// var = 123;
// ^---- getLocEnd() points here.
SourceLocation END = stmt->getLocEnd();
// MeasureTokenLength gets us past the last token, and adding 1 gets
// us past the ';'.
int offset = Lexer::MeasureTokenLength(END,
TheRewriter.getSourceMgr(),
TheRewriter.getLangOpts()) + 1;
SourceLocation END1 = END.getLocWithOffset(offset);
TheRewriter.InsertText(END1, "\n}", true, true);

Cocos2d-x: 0xC0000005: Access violation reading location 0xCDCDCDD1

everyone:
The problem is strange. I paste my code first.
void GameObjectsLayer::updateEnemy(float interval)
{
UNREFERENCED_PARAMETER(interval);
Enemy *lpEnemy = new Enemy("enemy1.png", 1, 10, 8);
lpEnemy->getSprite()->setAnchorPoint(CCPointZero);
lpEnemy->setPosition(ccp(-30, 400));
CCMoveTo *lpMoveAction = CCMoveTo::create(350.0f / ENEMY1_MOVE_SPEED, ccp(320, lpEnemy->getPosition().y));
CCCallFuncND *lpCallback = CCCallFuncND::create(lpEnemy->getSprite(), callfuncND_selector(GameObjectsLayer::removeEnemy), lpEnemy);
CCSequence *lpSeqActions = CCSequence::create(lpMoveAction, lpCallback, NULL);
this->addChild(lpEnemy->getSprite(), 10);
lpEnemy->getSprite()->runAction(lpSeqActions);
// When I set the breakpoint here, the _vEnemies is valid and the application runs well.
_vEnemies->push_back(lpEnemy);
}
void GameObjectsLayer::removeEnemy(CCNode *lpSender, void *lpParam)
{
Enemy *lpEnemy = (Enemy*)lpParam;
lpEnemy->getSprite()->stopAllActions();
this->removeChild(lpSender);
// When access the _vEnemies variable here, the exception occurs at "_vEnemies->begin()"
// I set a breakpoint here, the address of _vEnemies is invalid, but I set a breakpoint in the previous function, the _vEnemies has a valid address, what happened? I really can't comprehend the behavior. _vEnemies is the member variable of this class.
std::vector<Enemy*>::iterator iter = _vEnemies->begin();
while (iter != _vEnemies->end())
{
if (lpEnemy == *iter)
{
this->removeChild(lpEnemy->getSprite());
//delete *iter;
iter = _vEnemies->erase(iter);
continue;
}
++iter;
}
delete lpEnemy;
}
these two methods are used in two CCSchedules, which is intialized in init() method, the codes are below:
bool GameObjectsLayer::init()
{
bool bRet = false;
do
{
/* not important, omit them */
this->schedule(schedule_selector(GameObjectsLayer::updateEnemy), 5.0f);
this->schedule(schedule_selector(GameObjectsLayer::enemyShoot), 1.0f);
scheduleUpdate();
bRet = true;
}
while (0);
return bRet;
}
I got a head-ache. I don't know what happened. The version of my cocos2d-x is 2.1.5, and IDE is VS2012. Thanks for help..
Well, this is an old one, but for anyone who might stumble here :
The problem seems to be in this line
CCCallFuncND *lpCallback = CCCallFuncND::create(lpEnemy->getSprite(), callfuncND_selector(GameObjectsLayer::removeEnemy), lpEnemy);
The signature for this (from docs) is
static CCCallFuncND* create ( CCObject *pSelectorTarget,
SEL_CallFuncND selector,
void * d
)
*pSelectorTarget is the object on which the selector is called. So in this example it should be this instead of lpEnemy->getSprite().
Frankly, It seems a little strange to me that it didn't crash earlier.

if() doesn't seem to work - c++ opengl idle function

I want to make a little animation, a bridge with a traffic light witch warns when the bridge will open (yellow light) , red light while the bridge is animating (just moving u and down) and green light when it is down. For now I just want it to repeat the same animation over and over
In the idle function I have this code :
if(bridgeAnimating==0);
{
printf("\nwtf,%d\n",bridgeAnimating);
fflush(stdout);
startBridge=1;
}
animateBridge();
And this is what I get as output:
wtf,0
wtf,1
wtf,1...etc
bridgeAnimating is a global variable such as startBridge
int startBridge=0;
int bridgeAnimating=0;
And here is the function:
void animateBridge()
{
float static speed=0.25;
int static upwards=1;
double static warnTime=teid;
warnTime-=dt;
if(startBridge==1)
{
upwards=1;
bridgeAnimating=1;
warnTime=teid;
startBridge=0;
//printf("Here:Animating=%d",bridgeAnimating); //if un-commented this gets printed!!!
}
if(bridgeAngle<30 && upwards==1 && warnTime<=0)
{
bridgeAngle+=speed;
red=2;
green=0.9;
orangeRed=0.9;
orangeGreen=0.6;
bridgeAnimating=1;
printf("Upwnwards");
}else if(bridgeAngle>0 && upwards==0 && warnTime<=0)
{
bridgeAngle-=speed;
red=2;
green=0.9;
orangeRed=0.9;
orangeGreen=0.6;
bridgeAnimating=1;
printf("Downwards");
}else if(warnTime>0)
{
orangeRed=2;
orangeGreen=1.19;
red=0.9;
green=0.9;
bridgeAnimating=1;
//printf("Here"); //This gets printed if "un-commented"
}else
{
red=0.9;
green=2;
orangeRed=0.9;
orangeGreen=0.6;
bridgeAnimating=0;
printf("anim 0");//this doesn't print out
}
if(bridgeAngle>=30)
{
upwards=0;
}
}
I checked the document for other references of these 2 variables and there aren't any.
It must be something wrong with the algorithm but I can't figure it out.
I have a lot of global variables, this is the last one I added is it possible that the stack is full?
What is wrong here?
Your problem is this
if(bridgeAnimating==0);
The semicolon on the end indicates an empty statement, which is all that is being controlled by the if statement. Get rid of the ; and it will work as you expect.
Remove the trailing semi-colon:
if(bridgeAnimating==0);