Skip to content

Commit

Permalink
Merge pull request Automattic#660 from deadbeef84/windows-std-min-fix
Browse files Browse the repository at this point in the history
Wrap std::min calls in paranthesis to prevent macro expansion on windows
  • Loading branch information
LinusU committed Nov 9, 2015
2 parents 1568a31 + ff23127 commit 19a34b4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/CanvasRenderingContext2d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,10 @@ NAN_METHOD(Context2d::PutImageData) {
switch (info.Length()) {
// imageData, dx, dy
case 3:
cols = std::min(imageData->width(), context->canvas()->width - dx);
rows = std::min(imageData->height(), context->canvas()->height - dy);
// Need to wrap std::min calls using parens to prevent macro expansion on
// windows. See http://stackoverflow.com/questions/5004858/stdmin-gives-error
cols = (std::min)(imageData->width(), context->canvas()->width - dx);
rows = (std::min)(imageData->height(), context->canvas()->height - dy);
break;
// imageData, dx, dy, sx, sy, sw, sh
case 7:
Expand All @@ -617,8 +619,10 @@ NAN_METHOD(Context2d::PutImageData) {
if (dx < 0) sw += dx, sx -= dx, dx = 0;
if (dy < 0) sh += dy, sy -= dy, dy = 0;
// clamp width at canvas size
cols = std::min(sw, context->canvas()->width - dx);
rows = std::min(sh, context->canvas()->height - dy);
// Need to wrap std::min calls using parens to prevent macro expansion on
// windows. See http://stackoverflow.com/questions/5004858/stdmin-gives-error
cols = (std::min)(sw, context->canvas()->width - dx);
rows = (std::min)(sh, context->canvas()->height - dy);
break;
default:
return Nan::ThrowError("invalid arguments");
Expand Down

0 comments on commit 19a34b4

Please sign in to comment.