D.V.D
Make a wish
- Reaction score
- 73
Ok so I decided to try Visual Studio C++ 2010 Express. I created a new project that is a Win32 Application (not console) and I wanted to do something simple so I decided to make a draw circle function. I added a new header file and cpp file and I called the function in my cpp file from the main cpp file to actually run my code. Unfortunatly, I get a error for every variable I create in my code Here is my list of errors:
EDIT: I added the ';' signs to end of all lines of my code where they were missing. I still get the problems with type 'float' or short unexpected.
EDIT2: Fixed, spent too much time with python, forgot about some of the C++ rules
------ Build started: Project: Window Application, Configuration: Debug Win32 ------
DrawCircle.cpp
f:\my programs\window application\drawcircle.cpp(5): error C2062: type 'float' unexpected
f:\my programs\window application\drawcircle.cpp(6): error C2062: type 'float' unexpected
f:\my programs\window application\drawcircle.cpp(6): error C2630: ';' found in what should be a comma-separated list
f:\my programs\window application\drawcircle.cpp(7): error C2062: type 'short' unexpected
f:\my programs\window application\drawcircle.cpp(7): error C2630: ';' found in what should be a comma-separated list
f:\my programs\window application\drawcircle.cpp(8): error C2062: type 'int' unexpected
f:\my programs\window application\drawcircle.cpp(8): error C2630: ';' found in what should be a comma-separated list
f:\my programs\window application\drawcircle.cpp(9): error C2061: syntax error : identifier 'col'
f:\my programs\window application\drawcircle.cpp(11): error C2630: ';' found in what should be a comma-separated list
f:\my programs\window application\drawcircle.cpp(13): error C2065: 'x' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(13): error C2065: 'angle' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(14): error C2146: syntax error : missing ';' before identifier 'y'
f:\my programs\window application\drawcircle.cpp(14): error C2065: 'y' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(14): error C2065: 'angle' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(16): error C2146: syntax error : missing ';' before identifier 'SetPixel'
f:\my programs\window application\drawcircle.cpp(16): error C2065: 'x' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(16): error C2065: 'y' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(16): error C2065: 'col' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(18): error C2146: syntax error : missing ';' before identifier 'angle'
f:\my programs\window application\drawcircle.cpp(18): error C2065: 'angle' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(19): error C2065: 'step' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(19): error C2143: syntax error : missing ';' before '}'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Its weird because the files are linked properly so all of that works but I don't understand why it wouldn't be running simple variable calls. Heres my code ( main isn't posted cause of size of the code and I only added 2 lines to it so ill post my own functions.
Draw Circle.h
EDIT: I added the ';' signs to end of all lines of my code where they were missing. I still get the problems with type 'float' or short unexpected.
EDIT2: Fixed, spent too much time with python, forgot about some of the C++ rules
------ Build started: Project: Window Application, Configuration: Debug Win32 ------
DrawCircle.cpp
f:\my programs\window application\drawcircle.cpp(5): error C2062: type 'float' unexpected
f:\my programs\window application\drawcircle.cpp(6): error C2062: type 'float' unexpected
f:\my programs\window application\drawcircle.cpp(6): error C2630: ';' found in what should be a comma-separated list
f:\my programs\window application\drawcircle.cpp(7): error C2062: type 'short' unexpected
f:\my programs\window application\drawcircle.cpp(7): error C2630: ';' found in what should be a comma-separated list
f:\my programs\window application\drawcircle.cpp(8): error C2062: type 'int' unexpected
f:\my programs\window application\drawcircle.cpp(8): error C2630: ';' found in what should be a comma-separated list
f:\my programs\window application\drawcircle.cpp(9): error C2061: syntax error : identifier 'col'
f:\my programs\window application\drawcircle.cpp(11): error C2630: ';' found in what should be a comma-separated list
f:\my programs\window application\drawcircle.cpp(13): error C2065: 'x' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(13): error C2065: 'angle' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(14): error C2146: syntax error : missing ';' before identifier 'y'
f:\my programs\window application\drawcircle.cpp(14): error C2065: 'y' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(14): error C2065: 'angle' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(16): error C2146: syntax error : missing ';' before identifier 'SetPixel'
f:\my programs\window application\drawcircle.cpp(16): error C2065: 'x' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(16): error C2065: 'y' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(16): error C2065: 'col' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(18): error C2146: syntax error : missing ';' before identifier 'angle'
f:\my programs\window application\drawcircle.cpp(18): error C2065: 'angle' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(19): error C2065: 'step' : undeclared identifier
f:\my programs\window application\drawcircle.cpp(19): error C2143: syntax error : missing ';' before '}'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Its weird because the files are linked properly so all of that works but I don't understand why it wouldn't be running simple variable calls. Heres my code ( main isn't posted cause of size of the code and I only added 2 lines to it so ill post my own functions.
Draw Circle.h
Code:
#include "stdafx.h"
#include "Window Application.h"
#include <cmath>
void DrawCircle (HDC,int,int);
Code:
#include "stdafx.h"
#include "DrawCircle.h"
void DrawCircle (HDC hdc,int radius,int num):
float angle = 0;
float step = num/255;
short x = 0;
int y = 0;
COLORREF col=RGB(255,0,0)
while (angle < 255 ) {
x=radius*cos(angle)
y=radius*sin(angle)
SetPixel(hdc,x,y,col)
angle+=step
}