Jump to content
  • Advertisement
Sign in to follow this  
SomeoneX

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by SomeoneX
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...

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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!