Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Header function not being recognized

4: Adsense

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
7 replies to this topic

#1 thecheeselover   Members   

565
Like
0Likes
Like

Posted 15 May 2013 - 06:10 PM

Hello,

 

I have a Matrix4x4 template class in a header file. I've read that templates need to be only in headers (source: http://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file). Now, my problem is that when I change my header's code by adding a function and that I use this method somewhere (in main() in my case), then the compiler tells me my class Matrix4x4 doesn't contain the function. I thought that doing a rebuild would correct this error, but it doesn't work. Do you have any idea what I could do to fix this error?

 

Thank you,

Thecheeselover


Hide yo cheese! Hide yo wife!

#2 ApochPiQ   Moderators   

22544
Like
3Likes
Like

Posted 15 May 2013 - 11:07 PM

Can you post a minimal snippet of your code that reproduces the error?
Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

#3 thecheeselover   Members   

565
Like
0Likes
Like

Posted 16 May 2013 - 06:41 AM

Exemple:

namespace UCC
{
template <class T>
class Matrix4x4
{

    public:

    T m11, m12, m13, m14;
    T m21, m22, m23, m24;
    T m31, m32, m33, m34;
    T m41, m42, m43, m44;

    Matrix4x4()
    {
        m11 = 1;
        m12 = 0;
        m13 = 0;
        m14 = 0;

        m21 = 0;
        m22 = 1;
        m23 = 0;
        m24 = 0;

        m31 = 0;
        m32 = 0;
        m33 = 1;
        m34 = 0;

        m41 = 0;
        m42 = 0;
        m43 = 0;
        m44 = 1;
    }

    void SetIdentity()// not recognized
    {
        m11 = 1;
        m12 = 0;
        m13 = 0;
        m14 = 0;

        m21 = 0;
        m22 = 1;
        m23 = 0;
        m24 = 0;

        m31 = 0;
        m32 = 0;
        m33 = 1;
        m34 = 0;

        m41 = 0;
        m42 = 0;
        m43 = 0;
        m44 = 1;
    }
    static Matrix4x4 GetIdentity_S() // not recognized, don't know if there's an error here, I was testing when it didn't work
    {
        return Matrix4x4<T>();
    }
}
}


 

My main.cpp:

#include "Math/Matrix4x4.h"

using namespace UCC;

int main()
{
    Matrix4x4<float> matrix;
    matrix.SetIdentity(); // error: 'class UCC::Matrix4x4<float>' has no member named 'SetIdentity'|

    return EXIT_SUCCESS;
}


Hide yo cheese! Hide yo wife!

#4 Hodgman   Moderators   

50614
Like
1Likes
Like

Posted 16 May 2013 - 07:01 AM

Are you sure that "#include "Math/Matrix4x4.h"" is actually including that file? The reason I ask is because it contains a compile-time error. Perhaps you're editing one file but another is being included?



#5 RobTheBloke   Members   

2552
Like
0Likes
Like

Posted 16 May 2013 - 07:01 AM

Ignore me....


Edited by RobTheBloke, 16 May 2013 - 07:03 AM.


#6 thecheeselover   Members   

565
Like
0Likes
Like

Posted 16 May 2013 - 05:09 PM

Are you sure that "#include "Math/Matrix4x4.h"" is actually including that file? The reason I ask is because it contains a compile-time error. Perhaps you're editing one file but another is being included?

I checked if it was included by changing ''matrix.SetIdentity();'' to ''matrix.Transpose();'', which is another function in Matrix4x4.h, and it worked.

 

 

Ignore me....

???


Hide yo cheese! Hide yo wife!

#7 thecheeselover   Members   

565
Like
0Likes
Like

Posted 16 May 2013 - 05:52 PM

Are you sure that "#include "Math/Matrix4x4.h"" is actually including that file? The reason I ask is because it contains a compile-time error. Perhaps you're editing one file but another is being included?

You were right. I finally found the bug: the Matrix4x4 I was including wasn't the good one. The thing is I had the same Matrix4x4 class in another project and my current project still had dependencies to the old one. Thank you :)


Hide yo cheese! Hide yo wife!

#8 ApochPiQ   Moderators   

22544
Like
0Likes
Like

Posted 16 May 2013 - 06:32 PM

Please do not mark threads "solved" in the General Programming forum.

 

 

Thanks!


Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]




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.