Conversation
Eliminate Warning C4838: conversion from [X] to 'SHORT' requires a narrowing conversion
43825d0 to
c1ebfed
Compare
|
Was about to make a PR regarding the same error until I noticed your (@refack's) PR. //------------------------------------------------------------------------------
void win_screen_buffer::set_cursor(int column, int row)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(m_handle, &csbi);
const SMALL_RECT& window = csbi.srWindow;
int width = (window.Right - window.Left) + 1;
int height = (window.Bottom - window.Top) + 1;
column = clamp(column, 0, width);
row = clamp(row, 0, height);
COORD xy = { static_cast<SHORT> (window.Left + column), static_cast<SHORT> (window.Top + row) };
SetConsoleCursorPosition(m_handle, xy);
}
//------------------------------------------------------------------------------
void win_screen_buffer::move_cursor(int dx, int dy)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(m_handle, &csbi);
COORD xy = {
static_cast<SHORT> (clamp(csbi.dwCursorPosition.X + dx, 0, csbi.dwSize.X - 1)),
static_cast<SHORT> (clamp(csbi.dwCursorPosition.Y + dy, 0, csbi.dwSize.Y - 1)),
};
SetConsoleCursorPosition(m_handle, xy);
} |
I just don't like "recycling" variables, as per ES.26: Don’t use a variable for two unrelated purposes |
Makes sense. |
That's true, but since they store the result of
Sounds like a good idea. But anyway I'm not sure how actively maintained this repo is. My PR has been cooking for 20 days... |
|
Well it's the holidays right now (Ok it's 5 month since the last change, maybe the project is a bit stalled). Btw,- Happy holidays (and merry christmas if you are of a christian denomination) :). A bit OC: I'm not especially versed in github. I'm working on another PR and obviously it depends on your not yet merged PR to even build. To avoid later merge conflicts, I wonder how the right procedure is. Should I just add your changes to my local repo and then make the PR or does github have some mechanism to say that my PR is dependent on your PR? |
|
Found a solution. I just download your PR as a patch (you know the trick with appending the PR url with |
|
I would not expect any response on tickets or pull requests, even though @mridgers pushes code sometimes, he does not really communicate anymore. |
To get this to build with CL
19.16.27024.1on SDK10.0.18282.0Eliminate Warning C4838: conversion from [X] to 'SHORT' requires a narrowing conversion