Importing inline functions in MinGW
===

I'm using a shared library that defines inline functions in its header.

Here is a reduced test case, as seen by the compilation unit linking to the library (for the version seen by the library, just replace `dllimport` by `dllexport`).

    class __declspec(dllimport) MyClass {
    public:
        int myFunc2();
        int myFunc1();
    };
    
    inline int MyClass::myFunc2(void) {
        return myFunc1();
    }
    
    inline int MyClass::myFunc1(void) {
        return 0;
    }

Compiling this gives the warning:

> warning: 'int MyClass::myFunc1()' redeclared without dllimport
> attribute after being referenced with dll linkage [enabled by default]

Please note that the order in which the functions are defined is important, as putting the definition of `myFunc1` before the definition of `myFunc2` results in no warnings.

Note also that this code compiles without warnings under Visual C++. These warnings are specific at least to MinGW, maybe to GCC in general. Edit: it came to my mind that I may have to verify if the warning is not inhibited by one of the flags set by the project.

My questions are then:

 - Why this behavior ?
 - Declaring `myFunc1` as `inline` inside the class declaration fixes the problem. Why is that ? It's also against the [recommended way][1] of doing things.
 - Is there another (better ?) way to fix this problem ?


  [1]: http://www.parashift.com/c++-faq/where-to-put-inline-keyword.html