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. inline method Visual C++ 6

inline method Visual C++ 6

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
11 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.
  • R RadioOpa

    I have a problem with visual c++ V.6 Without the inline statement it works fine, with inline the compiler refuses creating code. Problem appears to be linked with "inline int CArray::getFw()" Here´s a sniplet: from CArray.h: typedef int T; class CArray { public: CArray( int, T = 0); int getFw(); void SetFeld( int, T ); T GetFeld( int); T& operator[ ](int ); virtual ~CArray(); private: int fw; T* p; }; from CArray.cpp: .... inline int CArray::getFw() { return fw; }

    C Offline
    C Offline
    Cedric Moonen
    wrote on last edited by
    #2

    What's the exact error message ?

    R 1 Reply Last reply
    0
    • C Cedric Moonen

      What's the exact error message ?

      R Offline
      R Offline
      RadioOpa
      wrote on last edited by
      #3

      Since it´s a German installation it´s: Generieren von Code... Linker-Vorgang läuft... Testprogramm.obj : error LNK2001: Nichtaufgeloestes externes Symbol "public: int __thiscall CArray::getFw(void)" (?getFw@CArray@@QAEHXZ) Debug/Testprogramm.exe : fatal error LNK1120: 1 unaufgeloeste externe Verweise Fehler beim Ausführen von link.exe. Browse-Informationsdatei wird erstellt... Testprogramm.exe - 2 Fehler, 0 Warnung(en)

      T C 2 Replies Last reply
      0
      • R RadioOpa

        Since it´s a German installation it´s: Generieren von Code... Linker-Vorgang läuft... Testprogramm.obj : error LNK2001: Nichtaufgeloestes externes Symbol "public: int __thiscall CArray::getFw(void)" (?getFw@CArray@@QAEHXZ) Debug/Testprogramm.exe : fatal error LNK1120: 1 unaufgeloeste externe Verweise Fehler beim Ausführen von link.exe. Browse-Informationsdatei wird erstellt... Testprogramm.exe - 2 Fehler, 0 Warnung(en)

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

        Kamann wrote:

        Since it´s a German installation

        since everyone here speak english, couldn't you traduce it ? (ok, it is a LNK2001, so MSDN tells it is an Unresolved external symbol, but please be compliant too...)


        TOXCCT >>> GEII power
        [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]

        O 1 Reply Last reply
        0
        • R RadioOpa

          Since it´s a German installation it´s: Generieren von Code... Linker-Vorgang läuft... Testprogramm.obj : error LNK2001: Nichtaufgeloestes externes Symbol "public: int __thiscall CArray::getFw(void)" (?getFw@CArray@@QAEHXZ) Debug/Testprogramm.exe : fatal error LNK1120: 1 unaufgeloeste externe Verweise Fehler beim Ausführen von link.exe. Browse-Informationsdatei wird erstellt... Testprogramm.exe - 2 Fehler, 0 Warnung(en)

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #5

          Did you include the .cpp file of your CArray in the project ? If yes, do you have the same error if you remove the inline keyword ?

          R 2 Replies Last reply
          0
          • C Cedric Moonen

            Did you include the .cpp file of your CArray in the project ? If yes, do you have the same error if you remove the inline keyword ?

            R Offline
            R Offline
            RadioOpa
            wrote on last edited by
            #6

            Hi Cedric the .cpp file is included and no, if I remove the inline keyword it works fine. my main application is called "testprogram" and it´s .cpp file contains #include #include #include #include #include #include #include #ifndef _ARRAY #include "Array.h" #endif where array.h is the header file from CArray.cpp

            1 Reply Last reply
            0
            • C Cedric Moonen

              Did you include the .cpp file of your CArray in the project ? If yes, do you have the same error if you remove the inline keyword ?

              R Offline
              R Offline
              RadioOpa
              wrote on last edited by
              #7

              I found the Problem: MS Visual C needs inline methods to be defined in the .h file rather than in the .cpp file. I moved the inline method from .cpp to .h and now it works fine. Odd This tells the MSDN Function Inlining Mixing inline and non-inline compile options on different modules can cause problems. Consider the following example that has: A library Test.lib with inline functions. A header file containing the function prototypes for the library (Test.h). An application App.exe, which is linking with Test.lib using the Test.h header file. If Test.lib is created with function inlining turned on (/Ob1 or /Ob2), you will get an unresolved external error on any inline functions from Test.lib that are used in App.exe. The function's address is not in the PST for Test.lib because the functions were inlined inside the library. You need to either disable inlining (/Ob0) when building the library or place the inline function code in the header file (Test.h). Similarly, a project that uses function inlining yet defines the functions in a source file rather than in the header file will also get this error. The header file is included everywhere deemed appropriate, but the functions are only inlined in the source file where they are defined. Therefore, the linker sees the functions as unresolved externals when used in other modules. For example: -- modified at 7:06 Friday 20th January, 2006

              1 Reply Last reply
              0
              • T toxcct

                Kamann wrote:

                Since it´s a German installation

                since everyone here speak english, couldn't you traduce it ? (ok, it is a LNK2001, so MSDN tells it is an Unresolved external symbol, but please be compliant too...)


                TOXCCT >>> GEII power
                [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]

                O Offline
                O Offline
                Owner drawn
                wrote on last edited by
                #8

                Ja

                Jesus Loves:rose:

                --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

                1 Reply Last reply
                0
                • R RadioOpa

                  I have a problem with visual c++ V.6 Without the inline statement it works fine, with inline the compiler refuses creating code. Problem appears to be linked with "inline int CArray::getFw()" Here´s a sniplet: from CArray.h: typedef int T; class CArray { public: CArray( int, T = 0); int getFw(); void SetFeld( int, T ); T GetFeld( int); T& operator[ ](int ); virtual ~CArray(); private: int fw; T* p; }; from CArray.cpp: .... inline int CArray::getFw() { return fw; }

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

                  Inlined functions have to be in headers files, so the code is visible to all CPP files that include the header. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

                  R 1 Reply Last reply
                  0
                  • M Michael Dunn

                    Inlined functions have to be in headers files, so the code is visible to all CPP files that include the header. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

                    R Offline
                    R Offline
                    RadioOpa
                    wrote on last edited by
                    #10

                    Hi Michael, is this just Microsoft specific or in general ? Do other Compilers require the same ? -- modified at 16:29 Saturday 21st January, 2006

                    M 1 Reply Last reply
                    0
                    • R RadioOpa

                      Hi Michael, is this just Microsoft specific or in general ? Do other Compilers require the same ? -- modified at 16:29 Saturday 21st January, 2006

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

                      That's just how inline functions work. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

                      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