Public Group

# expected unqualified id before string constant

This topic is 3625 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've been trying to figure out what's wrong with compiling my program. I think I've narrowed it down to a few lines that might be the problem, however I still have no idea what's wrong. I'm passing all of the right parameters into the functions, but it give the error "expected unqualified id before string constant" and shows me a line in math.h aka <cmath> Anyways, I think that this is the problem function. player.getX() and getY() return floats
void Enemy::fireShot1(float velocity)
{
float xVelocity = sqrt(fabs((velocity * velocity) - (player.getX() * player.getX())));
float yVelocity = sqrt(fabs((velocity * velocity) - (player.getY() * player.getY())));

createShot1(xPos, yPos, xVelocity, yVelocity, sprite);
}


Just out of curiosity, is it faster to do (variable * variable) or pow(variable, 2)?

##### Share on other sites
Quote:
 Original post by SomeoneXI've been trying to figure out what's wrong with compiling my program. I think I've narrowed it down to a few lines that might be the problem...

The code you pasted is unrelated to the error message in your thread topic. If that's your compiler's error output, it includes a line number on which the error occurred. Share that. Also, if possible, just share the whole file.

Quote:
 Just out of curiosity, is it faster to do (variable * variable) or pow(variable, 2)?

It's premature optimization. But (variable * variable) is faster.

##### Share on other sites
Well I'm pretty sure it's an error in my code.
The actual error line is in math.h, which is <cmath> so I doubt that's the actual problem, but the part it's complaining about is:

math.h
#ifndef	_MATH_H#define	_MATH_H	1#include <features.h>__BEGIN_DECLS //<<------ THIS LINE/* Get machine-dependent HUGE_VAL value (returned on overflow).   On all IEEE754 machines, this is +Infinity.  */#include <bits/huge_val.h>#ifdef __USE_ISOC99# include <bits/huge_valf.h># include <bits/huge_vall.h>

So it might be one of the things I used <cmath> for.

The only other function that uses it is this, however, which also seems OK.

double distance(int x1, int y1, int x2, int y2){    return sqrt(pow(x2 - x1, 2) + pow(x2 - x1, 2));}

##### Share on other sites
What do you include before cmath?

##### Share on other sites
I included:
"SDL/SDL.h"
"SDL/SDL_image.h"
"SDL/SDL_ttf.h"
<string>
<vector>

##### Share on other sites
Well this is rather embarrassing, after a bit of Google assisted searching I tried a few solutions. Turns out I forgot a semicolon after a class definition... woops.
Thanks for all of the help, though.

1. 1
Rutin
28
2. 2
3. 3
4. 4
5. 5

• 13
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632950
• Total Posts
3009424
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!