Jump to content

  • Log In with Google      Sign In   
  • Create Account


Effect error in debug mode


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 belfegor   Crossbones+   -  Reputation: 2507

Like
0Likes
Like

Posted 05 January 2013 - 06:23 PM

I got this error when i run my app in debug mode:

 

effect.fx... error X3074: "BonesMats": implicit array missing initial value

 

witch i don't understand why it is happening and how to resolve it.

 

Here are my details:

#define MAX_BONES_MATRICES     40
...
// and i create effect from file with this macros
D3DXMACRO effMacros[2];
        effMacros[0].Name       = "MAX_BONES_MATRICES";
        effMacros[0].Definition = to_string(MAX_BONES_MATRICES).c_str();
        effMacros[1].Name       = nullptr;
        effMacros[1].Definition = nullptr;
        LPD3DXBUFFER effectsErrors = NULL;
        hr = D3DXCreateEffectFromFile(
            device, fxFileName.c_str(), &effMacros[0],
            nullptr, 0, nullptr, &effect, &effectsErrors);
        if(FAILED(hr))
...

 

and in effect file i have this declaration that he is complaining about:

...
float4x4 BonesMats[MAX_BONES_MATRICES];

 

What am i missing?

Thank you for your time.



Sponsor:

#2 Nyssa   Members   -  Reputation: 426

Like
1Likes
Like

Posted 05 January 2013 - 08:25 PM

2 things I'd try...

1) Instead of:

effMacros[0].Definition = to_string(MAX_BONES_MATRICES).c_str();

 

Try:

effMacros[0].Definition = "40";

 

2) Is it a compile time error? If it's happening at runtime, make sure you are sending 40 matrices to the effect before rendering


Edited by Nyssa, 05 January 2013 - 08:30 PM.


#3 belfegor   Crossbones+   -  Reputation: 2507

Like
0Likes
Like

Posted 05 January 2013 - 08:38 PM

I dont understand why this is happening?

 

MessageBox(0, to_string(MAX_BONES_MATRICES).c_str(), 0, MB_OK); // message box says 40
        effMacros[0].Definition = "40";//to_string(MAX_BONES_MATRICES).c_str(); // but wont work here WTF?



#4 Nyssa   Members   -  Reputation: 426

Like
0Likes
Like

Posted 05 January 2013 - 08:46 PM

So this worked?

effMacros[0].Definition = "40";

 

The reason you would be seeing errors here is because "to_string" is returning a local variable (I'm guessing)  hence the string maybe destroyed after leaving the function "to_string".

So the reason it's working for the Message Box maybe just luck.


Edited by Nyssa, 05 January 2013 - 08:51 PM.


#5 belfegor   Crossbones+   -  Reputation: 2507

Like
0Likes
Like

Posted 05 January 2013 - 08:58 PM

to_string returns string copy not a reference to a local, and c_str() function returns const char* as this "40" literal type should be!!!

There is something strange happening, black magic?



#6 Nyssa   Members   -  Reputation: 426

Like
1Likes
Like

Posted 05 January 2013 - 09:05 PM

So it's returning a std::string?
Then try this:
 
std::string boneMatixString = to_string(MAX_BONES_MATRICES);
effMacros[0].Definition = boneMatixString.c_str();

 

 



#7 Anoop Chauhan   Members   -  Reputation: 115

Like
1Likes
Like

Posted 05 January 2013 - 10:00 PM

effMacros[0].Definition = std::to_string(MAX_BONES_MATRICES).c_str();

the lifetime of return constant character string is owned by class string, which has limited scope in your code( no persistent variable
is available of class string) ,you'd better to use code explained by Nyssa

 

std::string boneMatixString = to_string(MAX_BONES_MATRICES)

effMacros[0].Definition = boneMatixString.c_str();


Edited by Anoop Chauhan, 05 January 2013 - 10:01 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS