0

I work in C++, and I found some library, named "graphics.h". When I ran example code (I am a beginner in this library)

#include "graphics.h"
int main()
{ 
    int gd = DETECT, gm;
    initgraph(&gd, &gm, "");
    circle(250, 200, 50);
    getch();
    closegraph();
    return 0;
}

I get an error (Visual Studio 2019). Error is: '(E0100) duplicate parameter name' in graphics.h file. I found, that one function is defined like that:

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
    );

Look at the twice written int right. How can I repair it?

Also, I get the error in the example code: (E0167) 'argument of type "const char*" is incompatible with parameter of type "char *"'. Note, that I am just a beginner, so I don't know so much about chars and pointers.

I also get errors in graphics.h: 1. '(C2086) 'int right': redefinition', 2. '(C2664) 'void initgraph(int *,int *,char *)': cannot convert argument 3 from 'const char [1]' to 'char *'.

Am I the only one, who is having errors, or it is something bigger there?

Thank you for your effort !

Edit: I found some note on the library code: // * This library is still under development. and // * This library may not be compatible with 64-bit versions of Windows

I have no luck because I have 64-bit Windows 7 Professional.

genpfault
  • 51,148
  • 11
  • 85
  • 139
User123
  • 476
  • 7
  • 22
  • 1
    This looks like a bug in whatever library is associated with `"graphics.h"`. It sounds like a bad library. You can't really fix it yourself unless you compiled the library yourself. – François Andrieux Feb 28 '20 at 21:44
  • The error about `char*` conversion is probably also a library bug. It means you can't use a string literal. They really should have put `const char*` instead. I would stay away from this library. – François Andrieux Feb 28 '20 at 21:45
  • And is there another free library for graphics? – User123 Feb 28 '20 at 21:47
  • 2
    `#include "graphics.h"` -- This is the outdated and old BGI graphics from the Turbo C++ compilers. If you want to learn graphics programming, try something that isn't 25+ years old and is relevant for today's hardware and operating systems. – PaulMcKenzie Feb 28 '20 at 21:48
  • Search [softwarerecs.se] for graphics libraries. – Thomas Matthews Feb 28 '20 at 22:04
  • I'm going to break the rules and drop [SDL](https://www.libsdl.org/) and [SFML](https://www.sfml-dev.org/) here. Both are much more than just graphics libraries, but they contain good, and more importantly modern, graphics libraries. If you MUST use graphics.h, at least try to use [SDL-BGI](http://libxbgi.sourceforge.net/), graphics.h built atop SDL for a retro feel on modern hardware. – user4581301 Feb 28 '20 at 22:28
  • In a way it is good that you ran into a simple problem like this one early. most ports of BGI are so old they work poorly on any Windows system more recent than Windows XP. You often get a result that compiles and then either fails to run or s up in semi-random ways at inopportune times. – user4581301 Feb 28 '20 at 22:31
  • @PaulMcKenzie The funny thing is, that C++ itself is actually 25+ years old. (41 years). Just joking. :-) – User123 Mar 28 '20 at 20:04

0 Answers0