-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"forcing MSVC stacktrace to show which T we're talking about." error #980
Comments
I am using Visual Studio 2017 |
How does the exact code look like? The above error message is not triggered by parsing, but by trying to assign some user-defined object to |
@nlohmann The error was |
@gregmarr Right. Then it was an assignment from |
Ok, here all parts of the code, where I use nlohmann::json , sorry if my code is bad, but I am still a beginner and not used to c++: bool ItemLoader::loadItems()
{
std::ifstream itemFile("SaveFiles/items.json");
if (!itemFile.is_open()) return false;
json itemJ = json::parse(itemFile);
int i = 0;
while (!itemJ["Items"][i].is_null())
{
addItem(itemJ, i);
i++;
}
itemFile.close();
return true;
} void ItemLoader::addItem(json itemJ, int i)
{
Item item;
item.id = itemJ["Items"][i]["ID"];
item.itemName = itemJ["Items"][i]["Name"];
item.weight = itemJ["Items"][i]["weight"];
item.itemClass = itemClassParser(itemJ["Items"][i]["ItemClass"]);
item.itemRarity = itemRarityParser(itemJ["Items"][i]["ItemRarity"]);
item.itemAbilities = createAbilityVector(itemJ, i);
if (item.itemClass == ItemClass::chestplate || item.itemClass == ItemClass::gloves || item.itemClass == ItemClass::headgear || item.itemClass == ItemClass::legs) item.defense = itemJ["Items"][i]["defense"];
else if (item.itemClass == ItemClass::weapon || item.itemClass == ItemClass::magicalWeapon) {
item.physicalAttack = itemJ["Items"][i]["physicalAttack"];
item.magicAttack = itemJ["Items"][i]["magicAttack"];
item.weaponType = weaponTypeParser(itemJ["Items"][i]["weaponType"]);
item.ranged = itemJ["Items"][i]["ranged"];
}
items.push_back(item);
return;
} std::vector<ItemAbility> ItemLoader::createAbilityVector(json itemJ, int i)
{
std::vector<ItemAbility> abilities;
int c = 0;
while (!itemJ["Items"][i]["abilities"][c].is_null())
{
ItemAbility ability;
ability.abilityType = itemAbilityTypeParser(itemJ["Items"][i]["abilities"][c]["AbilityType"]);
if (ability.abilityType == ItemAbilityType::statIncrease) {
ability.statToIncrease = itemJ["Items"][i]["abilities"][c]["statToIncrease"];
ability.increasingAmount = itemJ["Items"][i]["abilities"][c]["increasingAmount"];
abilities.push_back(ability);
}
else if (ability.abilityType != ItemAbilityType::none){
ability.abilityFile = itemJ["Items"][i]["abilities"][c]["abilityFile"];
}
abilities.push_back(ability);
c++;
}
return abilities;
} character::character()
{
characterFile = "SaveFiles/character.json";
loadCharacter();
} bool character::loadCharacter()
{
std::ifstream charFile(characterFile);
if (!charFile.is_open()) return false;
json charJ = json::parse(charFile);
//load Status
status.agility = charJ["Status"]["agility"];
status.attributePoints = charJ["Status"]["attributePoints"];
status.charisma = charJ["Status"]["charisma"];
status.intelligence = charJ["Status"]["intelligence"];
status.luck = charJ["Status"]["luck"];
status.perception = charJ["Status"]["perception"];
status.skill = charJ["Status"]["skill"];
status.spiritAffinity = charJ["Status"]["spiritAffinity"];
status.spiritArmor = charJ["Status"]["spiritArmor"];
status.spiritEnergy = charJ["Status"]["spiritEnergy"];
status.strength = charJ["Status"]["strength"];
status.vitality = charJ["Status"]["vitality"];
status.wisdom = charJ["Status"]["wisdom"];
level = charJ["level"];
attackMultiplier = charJ["Attack Multiplier"];
name = charJ["name"];
int count = 0;
while (!charJ["inventory"][count].is_null()) {
addItem(charJ["inventory"][count]);
count++;
}
equipItem(charJ["Equipment"]["headgear"]);
equipItem(charJ["Equipment"]["chestplate"]);
equipItem(charJ["Equipment"]["gloves"]);
equipItem(charJ["Equipment"]["legs"]);
equipItem(charJ["Equipment"]["weapon1"]);
equipItem(charJ["Equipment"]["weapon2"], 2);
charFile.close();
return true;
} |
Then I would need to understand how, for instance, the |
Ok, solved it. The error was on my side. Thank you a lot for your help and explaining the error. |
Thanks for checking back! |
Hello, I am a beginner at c++ and get this error message, when I try to run my code:
Error C2338 forcing MSVC stacktrace to show which T we're talking about. ConsoleRPG c:...\nlohmann\json.hpp 1207
Error C2065 "force_msvc_stacktrace": undeclared identifier ConsoleRPG c:...\nlohmann\json.hpp 1206
Error C2039 "force_msvc_stacktrace": is not a member of "Item" ConsoleRPG c:...\nlohmann\json.hpp 1206
Error C2338 could not find from_json() method in T's namespace ConsoleRPG c:...\nlohmann\json.hpp 1202
I already read this thread: #929
I could still not locate the error.
The only thing I assign to json values is like this:
nlohmann::json itemJ = json::parse("string")
or having them as parameters in functions.
The text was updated successfully, but these errors were encountered: