Here’s my function. The width and height variables are global integer variables defined above this function with values in the hundreds.
#define ORIGINAL_WIDTH 800;
#define ORIGINAL_HEIGHT 700;
void set_perspective(void) {
int view_width, view_height;
if (width < height) {
view_width = width;
view_height = (float) width * ORIGINAL_HEIGHT / ORIGINAL_WIDTH;
}
else {
view_width = (float) height * ORIGINAL_WIDTH / ORIGINAL_HEIGHT;
view_height = height;
}
}
My C++ compiler notes “error C2143: syntax error : missing ‘;’ before ‘/'” on the lines:
view_height = (float) width * ORIGINAL_HEIGHT / ORIGINAL_WIDTH;
and
view_width = (float) height * ORIGINAL_WIDTH / ORIGINAL_HEIGHT;
Does this have to do with casting? Why am missing a semicolon somewhere? Thank you for your time.
Eschew macros (which are text substitutions) and use constants, and this problem can’t happen.