Link to home
Create AccountLog in
Avatar of bejhan
bejhan

asked on

Warning: statement with no effect

When I compile this in GCC with the -Wall option (required in my class) I get:

Warning: statement with no effect

This is on the lines where newX and newY are assigned values. I don't understand how this statement has no effect, newX and newY are receiving a new value aren't they?
void RotateMatrix(LINKEDLIST *matrices, char *line) {
	char name[MAX_MATRIX_NAME_LENGTH + 1];
	memset(name, 0, sizeof(name));
	long rotationAngle;
 
	//Parse the line to extract name and rotation angle
	int result = sscanf(line, "%*s %s %ld", name, &rotationAngle);
	if(result != 2) {
		char *error = "Couldn't extract matrix name/angle from rotate command";
		fprintf(stderr, error);
		exit(EXIT_FAILURE);
	}
 
	matrices->cursor->content = GetMatrix(matrices, name);
 
	long x, y, newX, newY;
	LINKEDLIST *coordinates = ((MATRIX *) matrices->cursor->content)->coordinates;
	coordinates->cursor = coordinates->head;
	while(coordinates->cursor != NULL) {
		x = ((COORDINATE *) coordinates->cursor->content)->x;
		y = ((COORDINATE *) coordinates->cursor->content)->y;
 
		switch(rotationAngle) {
			case 90:
				newX == -y;
				newY == x;
				break;
			case 180:
				newX == -x;
				newY == -y;
				break;
			case 270:
				newX == y;
				newY == -x;
				break;
		}
 
		((COORDINATE *) coordinates->cursor->content)->x = newX;
		((COORDINATE *) coordinates->cursor->content)->y = newY;
 
		coordinates->cursor = coordinates->cursor->next;
	}
 
	return;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of bejhan
bejhan

ASKER

Oh jeez, it should say Warning: Get some glasses :P
heh ;)