Try removing using namespace std.
I wrote a programm to draw circle in VS code using the msoftcon.h and msoftcon.cpp file, gives error
My program :
include <iostream>
using namespace std;
include "msoftcon.h"
class circle
{
protected:
int xC0, yC0;
int radius;
color fillcolor;
fstyle fillstyle;
public:
void set(int x, int y, int r, color fc, fstyle fs)
{
xC0 = x;
yC0 = y;
radius = r;
fillcolor = fc;
fillstyle = fs;
}
void draw()
{
set_color(fillcolor);
set_fill_style(fillstyle);
draw_circle(xC0, yC0, radius);
}
};
int main()
{
init_graphics();
circle c1;
circle c2;
circle c3;
c1.set(15, 7, 5, cBLUE, X_FILL);
c2.set(41, 12, 7, cRED, O_FILL);
c1.set(65, 18, 4, cGREEN, MEDIUM_FILL);
c1.draw();
c2.draw();
c3.draw();
set_cursor_pos(1, 25);
return 0;
}
when i run the code in VS code gives error like :
d:\mingw\x86_64-w64-mingw32\include\oaidl.h:579:5: error: reference to 'byte' is ambiguous
579 | byte *pRecord;
| ^~~~
In file included from d:\mingw\include\c++\11.2.0\bits\stl_algobase.h:61,
from d:\mingw\include\c++\11.2.0\bits\char_traits.h:39,
from d:\mingw\include\c++\11.2.0\ios:40,
from d:\mingw\include\c++\11.2.0\ostream:38,
from d:\mingw\include\c++\11.2.0\iostream:39,
from circle.cpp:4:
d:\mingw\include\c++\11.2.0\bits\cpp_type_traits.h:404:30: note: candidates are: 'enum class std::byte'
404 | enum class byte : unsigned char;
| ^~~~
In file included from d:\mingw\x86_64-w64-mingw32\include\wtypes.h:8,
from d:\mingw\x86_64-w64-mingw32\include\winscard.h:10,
from d:\mingw\x86_64-w64-mingw32\include\windows.h:97,
from msoftcon.h:8,
from circle.cpp:6:
d:\mingw\x86_64-w64-mingw32\include\rpcndr.h:63:25: note: 'typedef unsigned char byte'
63 | typedef unsigned char byte;
| ^~~~
I can't under the where is the issue. Please let me know what was the issue and how to resolve it ?
Developer technologies C++
2 additional answers
Sort by: Most helpful
-
Lalit Misal 21 Reputation points
2022-07-11T14:34:15.333+00:00 Thanks for the replay
now the above error has remove but new error getting appear.
Now the erroe is ,
d:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Lalit\AppData\Local\Temp\ccOoClKa.o:circle.cpp:(.text$_ZN6circle4drawEv[_ZN6circle4drawEv]+0x1b): undefined reference toset_color(color, color)'** d:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Lalit\AppData\Local\Temp\ccOoClKa.o:circle.cpp:(.text$_ZN6circle4drawEv[_ZN6circle4drawEv]+0x29): **undefined reference to
set_fill_style(fstyle)'
d:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Lalit\AppData\Local\Temp\ccOoClKa.o:circle.cpp:(.text$_ZN6circle4drawEv[_ZN6circle4drawEv]+0x47): undefined reference to `draw_circle(int, int, int)'in library file it is defined. what is the issue now
-
Lalit Misal 21 Reputation points
2022-07-12T06:16:26.707+00:00 Thanks for the replay,
I have added a library file msoftcon.h and msoftcon.cpp into the folder where my source code file is located and also i am using the VS code 2022 version 1.69.0.
only adding the library file into source folder is sufficient to compile and execute the source code?second point is i am new in c++ coding. I am using VS Code and minGW for my c++ coding. can you tell me the procedure for compiler or linker settings related to external libraries.