I cant compile this small code

This is a discussion on I cant compile this small code within the Game Programming forums, part of the General Programming Boards category; iv been learning to use the orge graphics engin im learning there tuts and i cpoyed and paste the 1st ...

  1. #1
    Registered User
    Join Date
    May 2006
    Location
    uk
    Posts
    14

    I cant compile this small code

    iv been learning to use the orge graphics engin im learning there tuts and i cpoyed and paste the 1st code but i keep getting a error here is the code

    Code:
    #include "ExampleApplication.h"
    
    class TutorialApplication : public ExampleApplication
    {
    protected:
    public:
        TutorialApplication()
        {
        }
    
        ~TutorialApplication() 
        {
        }
    protected:
        void createScene(void)
        {
        }
    };
    
    #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    #define WIN32_LEAN_AND_MEAN
    #include "windows.h"
    
    INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
    #else
    int main(int argc, char **argv)
    #endif
    {
        // Create application object
        TutorialApplication app;
    
        try {
            app.go();
        } catch( Exception& e ) {
    #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 
            MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
    #else
            fprintf(stderr, "An exception has occured: %s\n",
                    e.getFullDescription().c_str());
    #endif
        }
    
        return 0;
    }
    And there error i am getting is

    error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR'

    Thanks in advance

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    Looks like you're compiling with UNICODE enabled.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I recognise that code... OGRE!
    I stopped off at it before sticking with Irrlicht.
    </useless-offtopic-remark>
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    What a truly ugly way of managing cross-platform code.
    Just how many #ifdef's are there in the whole package?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    If it's supposed to be cross-platform, why not leave the WinMain() out altogether?
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,510
    because it provides portability through #define
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    int main() seems pretty portable to me ;p
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  8. #8
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,510
    But just not what Windows needs for it to run there I guess
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  9. #9
    Registered User
    Join Date
    May 2006
    Location
    uk
    Posts
    14
    cheeer guys maged to get it sorted

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compile Errors in my Code. Can anyone help?
    By DGLaurynP in forum C Programming
    Replies: 1
    Last Post: 10-06-2008, 09:36 AM
  2. Can you create, edit and compile C code with a C++ IDE?
    By nerdpirate in forum C Programming
    Replies: 4
    Last Post: 05-31-2008, 01:54 AM
  3. Visual Studio 2005 - Debug code with compile errors?
    By Swerve in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-17-2008, 08:12 AM
  4. anti-standard code can compile -- about template class
    By George2 in forum C++ Programming
    Replies: 10
    Last Post: 03-07-2008, 05:14 AM
  5. Can you compile the following template function code?
    By George2 in forum C++ Programming
    Replies: 8
    Last Post: 03-06-2008, 07:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21