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. problem with inline keyword

problem with inline keyword

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 5 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.
  • D Offline
    D Offline
    dart13
    wrote on last edited by
    #1

    I have a function in CDocument file which I declared inline. When I call it from CView class, the linker reports LNK2001 error. If it's not inline then it works fine. Does anyone know what might be the problem?

    B M 2 Replies Last reply
    0
    • D dart13

      I have a function in CDocument file which I declared inline. When I call it from CView class, the linker reports LNK2001 error. If it's not inline then it works fine. Does anyone know what might be the problem?

      B Offline
      B Offline
      bneacetp
      wrote on last edited by
      #2

      dart13 wrote: Does anyone know what might be the problem? Are you declaring a function inline that you have overridden from an MFC class CDocument? Just a wild guess. Does the link error give any other info? Happy Programming and God Bless! Internet::WWW::CodeProject::bneacetp

      D 1 Reply Last reply
      0
      • B bneacetp

        dart13 wrote: Does anyone know what might be the problem? Are you declaring a function inline that you have overridden from an MFC class CDocument? Just a wild guess. Does the link error give any other info? Happy Programming and God Bless! Internet::WWW::CodeProject::bneacetp

        D Offline
        D Offline
        dart13
        wrote on last edited by
        #3

        The function is a member function of derived CDocument class, and I use it to access protected member variable which I created. If it is used within CMyDoc then it's ok, but when I call it from CMyView then the linker reports that error. Here is a full text of the error msg: MyVew.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CMyDoc::IsButtonPressed(void)const " (?IsButtonPressed@CMyDoc@@QBE_NXZ)

        1 Reply Last reply
        0
        • D dart13

          I have a function in CDocument file which I declared inline. When I call it from CView class, the linker reports LNK2001 error. If it's not inline then it works fine. Does anyone know what might be the problem?

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          Is the code in the header file? The code for an inline function must be in a header file, because the code needs to be visible to every CPP file that calls the function. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot stop me with paramecium alone!

          T D 2 Replies Last reply
          0
          • M Michael Dunn

            Is the code in the header file? The code for an inline function must be in a header file, because the code needs to be visible to every CPP file that calls the function. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot stop me with paramecium alone!

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #5

            isn't the inline keyword made for declaring a function inline, wherever the code is written ?


            TOXCCT >>> GEII power

            A 1 Reply Last reply
            0
            • T toxcct

              isn't the inline keyword made for declaring a function inline, wherever the code is written ?


              TOXCCT >>> GEII power

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

              no it's not. the compiler has to know to sources to "convert" it to code that fits in the calling function! Don't try it, just do it! ;-)

              1 Reply Last reply
              0
              • M Michael Dunn

                Is the code in the header file? The code for an inline function must be in a header file, because the code needs to be visible to every CPP file that calls the function. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot stop me with paramecium alone!

                D Offline
                D Offline
                dart13
                wrote on last edited by
                #7

                Thanks for help. The inline function was in a CPP file. Does this rule of putting inline functions in a header file applies only to VC++ or it is a part of standard?

                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