Multiplication Interpreted as Pointer

Not much to say really...this isn't working and I don't have a clue how to fix it without putting them all in separate statements which I assume you wouldn't have to do. Anyway, here it is:

angle = 2 * PI * i / circle_points;

If it matters, angle is a double, PI is a #defined double, i is an integer and circle_points is an integer.

Thanks for any help

This code below does not interpret integers as pointers. What are you doing differently?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#define PI 3.14159

int main()
{
double angle;
int i = 10;
int circle_points = 50;
angle = 2 * PI * i / circle_points; 

std::cout << angle;

return 0;
}
Last edited on
hmm...well, here is the full code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <SFML\Window.hpp>
#define PI 3.141592653589793238462643383279503;
#define X .525731112119133606 
#define Z .850650808352039932
using namespace std;

sf::Window App(sf::VideoMode(800, 600, 32), "OpenGL Thing");

int main()
{
	while (App.IsOpened())
	{
		GLint circle_points = 100; 
		glBegin(GL_LINE_LOOP); 
		for (int i = 0; i < circle_points; i++) 
		{    
			double angle = 2 * PI * i / circle_points; 
			glVertex2f(cos(angle), sin(angle)); 
		} 
		glEnd();
		App.Display();
	}
}


The error is on the 'i', it says Operand of '*' must be a pointer.
Last edited on
closed account (1vRz3TCk)
#define PI 3.141592653589793238462643383279503; delete the ;
Thanks, that fixed it

Why does the semi-colon break it? Wouldn't it just create an empty statement?
closed account (1vRz3TCk)
When you compile the preprocessor replaces PI in the code with 3.141592653589793238462643383279503;, so the line with the error becomes:
double angle = 2 * 3.141592653589793238462643383279503; * i / circle_points;

Edit:
It would be better to use:
const double PI = 3.1etc.; instead of #define...
Last edited on
Topic archived. No new replies allowed.