Sign in to follow this  
BaneTrapper

Issues with IDE Linker? Why is this happening, and how do i fix it?

Recommended Posts

Hello, recently i separated one file intro multyple, now i am having compiler complain some of classes having unknown variables.

//The function
int Object::GetAttackDamage()
{
	int damage = 0;
	if (inventory != NULL)
	{
		BaseItem * equWep = unit->GetEquipedWeapon();
		if (equWep != NULL)
		{
			damage += equWep->wepDamage;
		}
	}

	if(unit)
		damage += unit->attackDamage;
	return damage;
}

//The error
C:/Prog/Code/src/Objects.cpp:155:22: error: 'class BaseItem' has no member named 'wepDamage'
damage += equWep->wepDamage; 

I can confirm that Objects.cpp includes Inventory.h which includes BaseItem.h Which has class BaseItem which inherites BaseItemWeapon which has this member, its publicly inherited so its visible. I don't know whats happening, or what have i done wrong sad.png

 

Here are raw cut outs of data from project, its clearly visible it is correct AFAIK.

http://pastebin.com/QcdcpXZM

 

What are common issues, and how would i go solving this issue? I have no clue what to do...

Edited by BaneTrapper

Share this post


Link to post
Share on other sites

Maybe the include guards on lines 21, 22, 46, 47 and the #endif at the end of the file are messing things up, maybe they shouldnt be there at all after you moved things around?

Also where is this Object class?

Edited by NumberXaero

Share this post


Link to post
Share on other sites

Oh god, i forgot to update, i fixed it. Header guard had name conflict... 

And yes, thank you for help. I decided to find issue my self, and i forgot about this post. I Was stuck for some time, and i was getting nowhere so i felt supper down. I really appreciate your help!

Share this post


Link to post
Share on other sites

I also strongly recommend using #pragma once instead of include guards to avoid this sort of thing.  It gets especially silly in larger projects where you'll often have multiple files with the same name.

But isn't #pragma once MSVC only? is it crossplatform?, if not. That's why i use #include/

Share this post


Link to post
Share on other sites

#pragma once is not msvc only like it once was. Any compiler worth it's salt supports it. I think it's even recommended by the GCC community to use pragma once.

 

Yes, it's not standard, but it is the most standard non-standard standard I know. ;)

Edited by jacmoe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this