Results 1 to 5 of 5

Thread: Is it possible to inline C++ DLL subs/functions? [RESOLVED]

  1. #1

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Is it possible to inline C++ DLL subs/functions? [RESOLVED]

    I got an error trying last time, but is it possible to inline functions and subs for a DLL file?

    Code:
    int _stdcall test()
    {
    //where do I stick the inline statement at?
    }

  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: Is it possible to inline C++ DLL subs/functions?

    If you are exporting the function, then no, it doesn't make much sense to inline it since other applications need to have access to it.
    If it's a helper function of some sort that is not exported, then sure, you can mark it as inline:
    Code:
    inline void foo()
    {
    }
    But in your example, there's no reason to declare a calling convention *and* inline -- if you inline the function, there is no function call to be made, and hence no calling convention to be used

    Also keep in mind that the "inline" statement is merely a suggestion to the compiler -- if the compiler disagrees with you about inlining the function it won't do it, even if you mark it as inline. To work around this you can use __forceinline (visual C++) or __attribute__((always_inline)) (gcc) instead, although even then the compiler might determine that the function isn't suitable to be inlined.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  3. #3

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Is it possible to inline C++ DLL subs/functions?

    Ok, so if there's no point of inlining when using _stdcall, is there anything else i can use or am I stuck with the way it is?

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Is it possible to inline C++ DLL subs/functions?

    inlining is something that happens during compilation. A DLL isn't involved until the linking stage. So no, you can never import the functions exported from a DLL as inline.

    However, the DLL usually has a header file accompanying it. Small functions that the users of the DLL might find useful might be defined as inline in there.

    However, if there are no such functions, and you don't have the DLL source code, there's nothing you can do.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Is it possible to inline C++ DLL subs/functions?

    Ok thanks. I guess it's not possible then.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width