inline method Visual C++ 6
-
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; }
What's the exact error message ?
-
What's the exact error message ?
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)
-
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)
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...] -
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)
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 ?
-
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 ?
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
-
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 ?
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
-
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...]Ja
Jesus Loves:rose:
--Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:
-
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; }
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
-
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
-
Hi Michael, is this just Microsoft specific or in general ? Do other Compilers require the same ? -- modified at 16:29 Saturday 21st January, 2006
That's just how inline functions work. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ