Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WinMain as a member function

WinMain as a member function

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++java
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    super_matt
    wrote on last edited by
    #1

    Hello, i am fairly new to c++ (worked mainly with java 'til now) and i was wondering if anybody could help me with with a certain linker error i am getting, the error that tells me i have unresolved externals (lnk2001, lnk2019) specifically in "_WinMain" in "_CRTstartup@16" i think this has something to do with my WinMain method be a member function (it is static so there is no hidden "this" parameter) but don't don't know what else to do, is my WinMain declaration: static int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) thanks to anyone who can help me.

    D I A 3 Replies Last reply
    0
    • S super_matt

      Hello, i am fairly new to c++ (worked mainly with java 'til now) and i was wondering if anybody could help me with with a certain linker error i am getting, the error that tells me i have unresolved externals (lnk2001, lnk2019) specifically in "_WinMain" in "_CRTstartup@16" i think this has something to do with my WinMain method be a member function (it is static so there is no hidden "this" parameter) but don't don't know what else to do, is my WinMain declaration: static int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) thanks to anyone who can help me.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Please consult the docs for compiler/linker errors! You need to create an entry point to wWinMainCRTStartup. Go to the Project Settings dialog box. Click the Link tab, and click Output in the Category box.


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      1 Reply Last reply
      0
      • S super_matt

        Hello, i am fairly new to c++ (worked mainly with java 'til now) and i was wondering if anybody could help me with with a certain linker error i am getting, the error that tells me i have unresolved externals (lnk2001, lnk2019) specifically in "_WinMain" in "_CRTstartup@16" i think this has something to do with my WinMain method be a member function (it is static so there is no hidden "this" parameter) but don't don't know what else to do, is my WinMain declaration: static int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) thanks to anyone who can help me.

        I Offline
        I Offline
        Iain Clarke Warrior Programmer
        wrote on last edited by
        #3

        The compiler is right, as is the previous replier. The stub code from the compiler is trying to link to a WinMain function. You've provided a static (well done!) function in a class, which is not actually called WinMain. Its name is CMyClass::WinMain. Just to complicate things, due to overloading considerations it will actually be called £$%^&CMyClass£$%^&WinMain£$%^&. The punctuation is my pretend name decoration. So you need a class plain WinMain function. Feel free to have only one line of code in it which calls your class's static WinMain function though. Iain.

        1 Reply Last reply
        0
        • S super_matt

          Hello, i am fairly new to c++ (worked mainly with java 'til now) and i was wondering if anybody could help me with with a certain linker error i am getting, the error that tells me i have unresolved externals (lnk2001, lnk2019) specifically in "_WinMain" in "_CRTstartup@16" i think this has something to do with my WinMain method be a member function (it is static so there is no hidden "this" parameter) but don't don't know what else to do, is my WinMain declaration: static int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) thanks to anyone who can help me.

          A Offline
          A Offline
          Alexander M
          wrote on last edited by
          #4

          try #pragma comment( linker, "/ENTRY:WinMain" ), but the function mustn have any parameters!! get the hinstance by GetModuleHandle, and the cmdline by GetCommandLine Don't try it, just do it! ;-)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups