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

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

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

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 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 on other sites
Or don't use include guards like that because the Big Three of compilers a normal person is likely to encounter all support '#pragma once'.

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 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.

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 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 on other sites

Even IBM XL supports #pragma once since version 13.1.1. The only "big" (euphemism!) missing should be solaris IDE...