Problems with inline functions in visual c++

This is a discussion on Problems with inline functions in visual c++ within the C++ Programming forums, part of the General Programming Boards category; I'm currently developing a 3d graphics engine for a school project, but yesterday I began experiencing trouble when I wanted ...

  1. #1
    Unregistered
    Guest

    Problems with inline functions in visual c++

    I'm currently developing a 3d graphics engine for a school project, but yesterday I began experiencing trouble when I wanted to separate the interface from the implementation by placing them in separate files, now, the trouble is that I've inlined such parts of the program that would cause a noticable speed increase alternatively a size decrement, although, when I separated the interface and implementation the compiler seemed to belive that the functions which I have inlined were missing. I thought the problem might be me inlining the functions..it was..., but...isn't there any way of having the inlined functions in a source file which is separated from the implementation file. Here's some code to illustrate my problem:

    This is the example interface file:

    //----[Interface]------------------------------

    class gc_SomeClass {
    public:
    inline gc_SomeClass();
    inline ~gc_SomeClass();
    // Some routines.
    protected:
    // Some data.
    };


    This is the sample implementation file.

    //----[Implementation]----------------------

    #include "SomeClass.h"

    //------------------------------------------------

    gcSomeClass::gcSomeClass() {
    }

    //------------------------------------------------

    gcSomeClass::~gcSomeClass() {
    }
    //------------------------------------------------

  2. #2
    Registered User Coder's Avatar
    Join Date
    Aug 2001
    Location
    Cairo, Egypt
    Posts
    128
    When you inline functions, the compiler expects to see the code when compiling so that it can replace the function calls with the function code.
    Thus, you can't define inline files in a separate implementation file this way. You can, however, put your inline functions in a .inl file and include it in the header file, at the end :
    Code:
    //----[Interface]------------------------------
    class gc_SomeClass {
    public:
    inline gc_SomeClass();
    inline ~gc_SomeClass();
    // Some routines.
    protected:
    // Some data.
    };
    
    #include "SomeClass.inl"
    Muhammad Haggag

  3. #3
    Unregistered
    Guest
    I came up with a different solution, but thanks anyway

  4. #4
    Registered User Coder's Avatar
    Join Date
    Aug 2001
    Location
    Cairo, Egypt
    Posts
    128
    I'd be glad to read yours, if it's OK
    Muhammad Haggag

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Functions in C
    By shoobsie in forum C Programming
    Replies: 15
    Last Post: 11-17-2005, 12:47 PM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  4. MS Visual C++ 6 wont include vector.h in a header file
    By bardsley99 in forum C++ Programming
    Replies: 9
    Last Post: 11-06-2003, 11:05 AM
  5. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 09:04 PM

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