-
November 6th, 2013, 05:34 PM
#16
Re: [RESOLVED] errors about types
Code:
for (i=0; i<=tlen;i++)
indexes start at 0 and end 1 less than length of string.
Instead of
Code:
HANDLE hConIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
to get the handle for stdin, use
Code:
HANDLE hConIn = GetStdHandle(STD_INPUT_HANDLE);
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 6th, 2013, 05:59 PM
#17
Re: [RESOLVED] errors about types
Originally Posted by Cambalinho
strange if i execute normaly, i get the windows error, if i debug it theres no windows error... nothing
First:
Code:
SHORT tlen = static_cast<SHORT>(p->Text.length());
//...
for (i=0; i<=tlen;i++)
Honestly, you shouldn't be making these type of beginner mistakes or at least, not be able to identify this mistake if you debugged your code.
I'll make it easy for you -- if you're ever doing a "<=" for the ending of a loop, look at your loop again and what you're looping over (a container, a string, etc.). Chances are, the <= is not correct, and you're going 1 more than it should (but again, this should have been obvious to you without our help).
Second, when you do make these mistakes, there is no guarantee how your application will run. That's the nature of C++.
Regards,
Paul McKenzie
-
November 7th, 2013, 06:01 AM
#18
Re: [RESOLVED] errors about types
Originally Posted by Paul McKenzie
First:
Code:
SHORT tlen = static_cast<SHORT>(p->Text.length());
//...
for (i=0; i<=tlen;i++)
Honestly, you shouldn't be making these type of beginner mistakes or at least, not be able to identify this mistake if you debugged your code.
I'll make it easy for you -- if you're ever doing a "<=" for the ending of a loop, look at your loop again and what you're looping over (a container, a string, etc.). Chances are, the <= is not correct, and you're going 1 more than it should (but again, this should have been obvious to you without our help).
Second, when you do make these mistakes, there is no guarantee how your application will run. That's the nature of C++.
Regards,
Paul McKenzie
thanks for correct me.
"Second, when you do make these mistakes, there is no guarantee how your application will run. That's the nature of C++."
so that's why sometimes worked and others don't, right?
-
November 7th, 2013, 06:17 AM
#19
Re: [RESOLVED] errors about types
You had a buffer overrun error where your code was overwriting other data in memory it shouldn't have been. c++ provides no check for this. In this circumstance whether the program 'works' or not depends upon the luck of the draw, what happens to be in memory at the time, the phase of the moon, the state of the tide..... It might work a few times then fail, it might work until a re-boot. It might always work on your computer but fail on another...
These type of errors are a nightmare to trace as they are not always repeatable and adding debug code can sometimes seem to 'cure' the problem but is only making the problem move about to resurface somewhere else. Trying to debug a program that 'occasionally fails' is the stuff of nightmares - so when dealing with memory be extra careful and vigulent about how you are dealing with it.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 7th, 2013, 06:19 AM
#20
Re: [RESOLVED] errors about types
Originally Posted by 2kaud
thanks for that.. thanks to both.. realy thanks
-
November 7th, 2013, 06:24 AM
#21
Re: [RESOLVED] errors about types
anotherthing: what you, both, think about my Blink connection?
the SetColorAndBackground() do the connection with Write() that test it and, if is true, call the Blink
-
November 7th, 2013, 06:26 AM
#22
Re: [RESOLVED] errors about types
Originally Posted by Cambalinho
anotherthing: what you, both, think about my Blink connection?
the SetColorAndBackground() do the connection with Write() that test it and, if is true, call the Blink
How do you stop the text blinking?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 7th, 2013, 06:30 AM
#23
Re: [RESOLVED] errors about types
Originally Posted by 2kaud
How do you stop the text blinking?
good one!!!!! only the program stop it
-
November 7th, 2013, 06:34 AM
#24
Re: [RESOLVED] errors about types
for the moment i can't identify the threads\process's. but maybe with Clear() and ~console() i can stop them
-
November 7th, 2013, 06:37 AM
#25
Re: [RESOLVED] errors about types
1 question: i can do a blink bool inside the Blink.h, if i use it inside the infinite loop will stop all threads in same time?
-
November 7th, 2013, 06:43 AM
#26
Re: [RESOLVED] errors about types
the answer is yes... i have tested now with cout. i had 4 blinks, so the cout prints 4 times... thanks for all
TextBlink.h
Code:
#include <windows.h>
#include <process.h>
#include <string>
#include <iostream>
using namespace std;
//ForeColor
const int ForeColorBlack = 0;
const int ForeColorBlue = FOREGROUND_BLUE;
const int ForeColorGreen = FOREGROUND_GREEN;
const int ForeColorCyan = FOREGROUND_BLUE | FOREGROUND_GREEN;
const int ForeColorRed = FOREGROUND_RED;
const int ForeColorMagenta = FOREGROUND_BLUE | FOREGROUND_RED;
const int ForeColorBrown = FOREGROUND_GREEN | FOREGROUND_RED;
const int ForeColorLightGray = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
const int ForeColorDarkGray = FOREGROUND_INTENSITY;
const int ForeColorLightBlue = FOREGROUND_BLUE | FOREGROUND_INTENSITY;
const int ForeColorLightGreen = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
const int ForeColorLightCyan = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
const int ForeColorLightRed = FOREGROUND_RED | FOREGROUND_INTENSITY;
const int ForeColorLightMagenta = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY;
const int ForeColorYellow = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
const int ForeColorWhite = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
//BackColor
const int BackColorBlack = 0;
const int BackColorBlue = BACKGROUND_BLUE;
const int BackColorGreen = BACKGROUND_GREEN;
const int BackColorCyan = BACKGROUND_BLUE | BACKGROUND_GREEN;
const int BackColorRed = BACKGROUND_RED;
const int BackColorMagenta = BACKGROUND_BLUE | BACKGROUND_RED;
const int BackColorBrown = BACKGROUND_GREEN | BACKGROUND_RED;
const int BackColorLightGray = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED;
const int BackColorDarkGray = BACKGROUND_INTENSITY;
const int BackColorLightBlue = BACKGROUND_BLUE | BACKGROUND_INTENSITY;
const int BackColorLightGreen = BACKGROUND_GREEN | BACKGROUND_INTENSITY;
const int BackColorLightCyan = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY;
const int BackColorLightRed = BACKGROUND_RED | BACKGROUND_INTENSITY;
const int BackColorLightMagenta = BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY;
const int BackColorYellow = BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
const int BackColorWhite = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
bool blBlink=true;
struct Blink
{
string Text;
SHORT x;
SHORT y;
WORD Attributes;
};
unsigned __stdcall BlinkLoop(void *params)
{
Blink *p = static_cast<Blink *>(params);
SHORT tlen = static_cast<SHORT>(p->Text.length());
SHORT x=p->x, y=p->y;
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
const char *text=(char*)p->Text.c_str();
CHAR_INFO *ConsoleText= new CHAR_INFO[tlen];
CHAR_INFO *EmptyConsoleText= new CHAR_INFO[tlen];
COORD a={tlen,1}, b={0,0};
SMALL_RECT c={x, y,SHORT(x+tlen),SHORT(y+1)};
int i=0;
for (i=0; i<tlen;i++)
{
ConsoleText[i].Char.AsciiChar =text[i];
ConsoleText[i].Attributes=p->Attributes;
EmptyConsoleText[i].Char.AsciiChar =' ';
EmptyConsoleText[i].Attributes=p->Attributes;
}
while (blBlink==true)
{
WriteConsoleOutput(hout,ConsoleText,a,b,&c);
Sleep(500);
WriteConsoleOutput(hout,EmptyConsoleText,a,b,&c);
Sleep(500);
}
cout << "\noi\n";//readers\programmers, you can take off these line.. these line was only for test ;)
return 0;
}
void TextBlink(const string Text, SHORT x, SHORT y, const WORD TextAttribute=ForeColorWhite | ForeColorBlack)
{
Blink *b = new Blink;
b->Text = Text;
b->Attributes=TextAttribute;
b->x=x;
b->y =y;
blBlink=true;
_beginthreadex(NULL, 0, BlinkLoop, b, 0, NULL);
}
console.h
Code:
/*heres a nice class for work with console commands, properties and events*/
/*#ifndef myheadguard1
#define myheadguard1
//insert contents of header here
#endif*/
#include <iostream>
#include <typeinfo>
#include <string>
#include <Windows.h>
#include <conio.h>
#include <sstream>
#include <cstddef>
#include <typeinfo>
#include <stdio.h>
#include <clocale>
#include "TextBlink.h"
#define MY_BUFSIZE 1024
const std::string NewLine = "\n";
using namespace std;
struct Position
{
int X;
int Y;
};
struct Size
{
int Width;
int Height;
};
class Console
{
private:
char pszOldWindowTitle[MY_BUFSIZE];
HWND ConsoleHandle;
HDC ConsoleDC;
bool blnVisible;
bool ReadEnter=false; //these boolean variable is for distinguish the functions used;)
//properties
DWORD GetConsoleSize(HANDLE sout, COORD& size)
{
CONSOLE_FONT_INFO cfinfo;
COORD fsize;
WINDOWINFO winfo;
if (!GetCurrentConsoleFont(sout, FALSE, &cfinfo))
{
return (GetLastError());
}
fsize = GetConsoleFontSize(sout, cfinfo.nFont);
if (!fsize.X && !fsize.Y)
{
return (GetLastError());
}
winfo.cbSize = sizeof(WINDOWINFO);
if (!GetWindowInfo(GetConsoleWindow(), &winfo))
{
return (GetLastError());
}
size.Y = (SHORT)((winfo.rcClient.bottom - winfo.rcClient.top) / fsize.Y);
size.X = (SHORT)((winfo.rcClient.right - winfo.rcClient.left) / fsize.X);
return (0);
}
bool blCaretVisible;
bool blnBlink=false;
public:
static void Printed();
//initializate
Console ()
{
COORD consize;
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleSize(hcon, consize);
SetConsoleScreenBufferSize(hcon, consize);
SetVisible(true);
}
~Console()
{
blBlink=true;
}
Console (void (*create) ())
{
COORD consize;
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleSize(hcon, consize);
SetConsoleScreenBufferSize(hcon, consize);
SetVisible(true);
create();
}
//HDC and Handle and Hwnd
HDC hdc()
{
return GetDC(GetConsoleWindow());
}
HWND hwnd()
{
return GetConsoleWindow();
}
HANDLE handle()
{
return GetStdHandle(STD_OUTPUT_HANDLE);
}
//Console title
string ConsoleTitle()
{
GetConsoleTitle( pszOldWindowTitle,MY_BUFSIZE);
return string(pszOldWindowTitle);
}
void ConsoleTitle(string title)
{
SetConsoleTitle(title.c_str());
}
//Console Position
POINT GetConsolePosition()
{
POINT a;
RECT WindowRect;
GetWindowRect(GetConsoleWindow() ,&WindowRect);
a.x=WindowRect.left;
a.y=WindowRect.top;
return a;
}
void SetConsolePosition(POINT Position )
{
SetWindowPos(GetConsoleWindow(),HWND_TOP,Position.x,Position.y,0,0,SWP_SHOWWINDOW||SWP_NOOWNERZORDER);
}
void write()
{
setlocale(LC_ALL, "en_US.UTF-8");
cout <<"";
Printed();
}
template <typename ...B>
void write(string argHead, B... argTail)
{
setlocale(LC_ALL, "en_US.UTF-8");
if (blnBlink==true)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
TextBlink(argHead, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
COORD Position;
Position.X=csbi.dwCursorPosition.X+strlen(argHead.c_str());
Position.Y=csbi.dwCursorPosition.Y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
}
else
cout << argHead;
write(argTail...);
}
template <typename ...B>
void write(char *argHead, B... argTail)
{
setlocale(LC_ALL, "en_US.UTF-8");
if (blnBlink==true)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
string a;
a=argHead;
TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
COORD Position;
Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
Position.Y=csbi.dwCursorPosition.Y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
}
else
cout << argHead;
write(argTail...);
}
template <typename A, typename ...B>
void write(A argHead, B... argTail)
{
setlocale(LC_ALL, "en_US.UTF-8");
if (blnBlink==true)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
string a;
a=to_string(argHead);
TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
COORD Position;
Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
Position.Y=csbi.dwCursorPosition.Y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
}
else
cout << argHead;
write(argTail...);
}
//Read
//empty
void read()
{
if (ReadEnter==false)
{
while(kbhit())
;
HANDLE hConIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
DWORD oldMode;
GetConsoleMode(hConIn, &oldMode);
SetConsoleMode(hConIn, ENABLE_LINE_INPUT);
FlushConsoleInputBuffer(hConIn);
char buffer[1];
DWORD read;
ReadConsoleA(hConIn, buffer, sizeof(buffer), &read, nullptr);
SetConsoleMode(hConIn, oldMode);
CloseHandle(hConIn);
}
}
template<typename ...B>
void read(string &s, B&... tail)
{
ReadEnter=true;
while(kbhit())
;
setlocale(LC_ALL, "en_US.UTF-8");
getline(cin, s);
read(tail...);
ReadEnter=false;
}
template<typename ...B>
void read(char s[256], B&... tail)
{
ReadEnter=true;
while(kbhit())
;
setlocale(LC_ALL, "en_US.UTF-8");
cin.getline(s,256);
read(tail...);
ReadEnter=false;
}
template <typename A, typename ...B>
void read(A &argHead, B&... argTail)
{
ReadEnter=true;
while(kbhit())
setlocale(LC_ALL, "en_US.UTF-8");
cin >> argHead;
read(argTail...);
ReadEnter=false;
}
//clear the Console
void Clear(int BackColor=-1)
{
// home for the cursor
COORD coordScreen = {0, 0};
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
blBlink=false;
// Get the number of character cells in the current buffer
if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
return;
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
// Fill the entire screen with blanks
if(!FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), (WCHAR)' ', dwConSize, coordScreen, &cCharsWritten))
return;
// Get the current text attribute.
if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
return;
if (BackColor!=-1)
{
DWORD textcolor = csbi.wAttributes & 0xff0f;
//DWORD backcolor = (csbi.wAttributes & 0xfff0) >> 4;
csbi.wAttributes=textcolor | BackColor ;//here we change the backcolor
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), csbi.wAttributes );
// Set the buffer's attributes accordingly.
if(!FillConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE), csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten))
return;
// Put the cursor at its home coordinates.
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coordScreen);
}
//Turn cursor on
DWORD CursorOn(HANDLE sout)
{
CONSOLE_CURSOR_INFO cur;
if (!GetConsoleCursorInfo(sout, &cur))
{
return (GetLastError());
}
cur.bVisible = TRUE;
return (!SetConsoleCursorInfo(sout, &cur) ? GetLastError() : 0);
}
//Turn cursor off
DWORD CursorOff(HANDLE sout)
{
CONSOLE_CURSOR_INFO cur;
if (!GetConsoleCursorInfo(sout, &cur))
{
return (GetLastError());
}
cur.bVisible = FALSE;
return (!SetConsoleCursorInfo(sout, &cur) ? GetLastError() : 0);
}
bool GetCaretVisible()
{
return blCaretVisible;
}
void SetCaretVisible(bool Visible)
{
if (Visible==true)
{
CursorOn(handle());
}
else
{
CursorOff(handle());
}
blCaretVisible=Visible;
}
void SetColorAndBackground(int ForgC, int BackC=0, bool Blink=false)
{
blnBlink=Blink;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ForgC | BackC );
}
void SetConsoleIcon(char *strIconPath)
{
HANDLE lIcon;
lIcon = LoadImage(0,strIconPath , 1, 0, 0, LR_LOADFROMFILE);
SendMessage(GetConsoleWindow() , WM_SETICON, 0,(LPARAM) lIcon) ;
}
COORD GetCaretPosition()
{
COORD s;
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
s.X=csbi.dwCursorPosition.X;
s.Y=csbi.dwCursorPosition.Y;
return s;
}
void SetCaretPosition(COORD Position)
{
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
}
bool GetVisible()
{
return blnVisible;
}
void SetVisible(bool visible)
{
if (visible== true)
{
ShowWindow(GetConsoleWindow(),SW_SHOWNORMAL);
}
else
{
ShowWindow(GetConsoleWindow(),SW_HIDE);
}
blnVisible=visible;
}
COORD GetConsoleWindowSize()
{
COORD consize;
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleSize(hcon, consize);
//SetConsoleScreenBufferSize(hcon, consize);
return consize;
}
void SetConsoleWindowSize(COORD Size)
{
SMALL_RECT s;
POINT WindowPos;
CONSOLE_SCREEN_BUFFER_INFO csbi;
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
WindowPos=GetConsolePosition() ;
s.Left=(SHORT)WindowPos.x;
s.Top=(SHORT)WindowPos.y;
s.Bottom=(SHORT)WindowPos.y+Size.Y;
s.Right= (SHORT)WindowPos.x+Size.X;
GetConsoleScreenBufferInfo( hcon, &csbi);
if (Size.X > (csbi.srWindow.Bottom- csbi.srWindow.Top) || Size.Y > (csbi.srWindow.Right- csbi.srWindow.Left))
{
SetConsoleScreenBufferSize(hcon, Size);
}
SetConsoleWindowInfo(hcon,true,&s);
}
}Console;
main.cpp
Code:
#include "console.h"
void Console::Printed()
{
cout << "\nHello world";
}
int main()
{
char Text[]="hello world fdsfdsaffdsafjkdsnaljkfdsbaohjfbodhsjalbfndsljabnlfjdspaifj";
string c ="oi";
int a=10;
double b=20.34;
Console.SetColorAndBackground(FOREGROUND_BLUE,BackColorCyan,true);
Console.Clear();
Console.read(Text);
Console.write(a,b,Text,c);
Console.read();
Console.Clear();
Console.read();
return 0;
}
so what you think?
Last edited by Cambalinho; November 7th, 2013 at 06:47 AM.
-
November 7th, 2013, 07:22 AM
#27
Re: [RESOLVED] errors about types
As you are setting/resetting blBlink in one thread and testing in another,
should be
Code:
volatile bool blBlink=true;
which is a hint to the compiler that blBlink may be changed without the compiler being aware of the fact so don't keep its value in a register, load its value every time from its actual memory location.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 7th, 2013, 07:30 AM
#28
Re: [RESOLVED] errors about types
Originally Posted by 2kaud
As you are setting/resetting blBlink in one thread and testing in another,
should be
Code:
volatile bool blBlink=true;
which is a hint to the compiler that blBlink may be changed without the compiler being aware of the fact so don't keep its value in a register, load its value every time from its actual memory location.
thanks for all
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|