WinBGIm error: redefinition of 'int right'

Jan 10, 2012 at 9:11am
I don't know whether it suits this forum or not but I just wanted to tell (the world) something. I recently decided to try out WinBGIm library, so I downloaded the package and after setting up all the compiler and linker settings, ran my simple "Hello World" Code. But I got the following message from my compiler (MinGW, CodeBlocks IDE).


d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\graphics.h|302|error: redefinition of 'int right'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\graphics.h|302|error: 'int right' previously declared here|
||=== Build finished: 2 errors, 0 warnings ===|


After having googled the problem I found out nothing (If you don't count a suggestion to use CodeBlocks-EP as a Solution).
As I was taking a look at the header files, I found the problem (yeah!!!)
The problem was with the function printimage.
The original declaration was

1
2
3
4
5
6
7
//The original declaration. Note that there are two "right" variables
void printimage(
    const char* title=NULL,	
    double width_inches=7, double border_left_inches=0.75, double border_top_inches=0.75,
    int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,
    bool active=true, HWND hwnd=NULL
    );


So what I did is that, I simply changed one of the "right" (the later former one) variable to "top". That's it.

1
2
3
4
5
6
7
//The corrected code
void printimage(
    const char* title=NULL,	
    double width_inches=7, double border_left_inches=0.75, double border_top_inches=0.75,
    int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,
    bool active=true, HWND hwnd=NULL
    );


As simple as that (shame on me to waste a full 2 hours at that problem). So, I decided to put this information for other many WinBGIm beginners.
Last edited on Jan 10, 2012 at 2:59pm
Jan 10, 2012 at 2:48pm
Is it possible that you changed the wrong 'right'? This way 'top' is equal to 'bottom' and 'left' to 'right' which is a rather strange rectangle ~0.

if you replace the first 'right' with 'top' and leave the second 'right' as is it'd be the maximum possible rectangle
Jan 10, 2012 at 2:59pm
@coder777, sorry, my bad. I shall edit it ASAP. And thanks for the correction..
Topic archived. No new replies allowed.