Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 730343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:54:03+00:00 2026-05-14T06:54:03+00:00

When trying to inline a function in Visual C++ (2008 express), I got a

  • 0

When trying to inline a function in Visual C++ (2008 express), I got a linking error, after a close inspection of the code, what I discovered is that the function I am trying to inline throws an exception… if I remove the exception throwing, the linking error goes away, can someone explain why it is the case?

int com_ximpleware::FastIntBuffer::intAt(int index){
    if (index < 0 || index > size - 1) {
       throw InvalidArgumentException("invalid index range in FastIntBuffer's intAt()");
    }
    return ((int *) al->get(index>>exp))[index & r];
}

The exaxt error is shown below:

intHash.obj : error LNK2019: unresolved external symbol "public: int __thiscall com_ximpleware::FastIntBuffer::intAt(int)" (?intAt@FastIntBuffer@com_ximpleware@@QAEHH@Z) referenced in function __catch$?isUnique@IntHash@com_ximpleware@@QAE_NH@Z$0
1>C:\new_cvs\cpp_test1\Debug\cpp_test1.exe : fatal error LNK1120: 1 unresolved externals

One more thing, this function was invoked else normally, the calling part of the function wasn’t included.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:54:04+00:00Added an answer on May 14, 2026 at 6:54 am

    You’ll have to place your definition in the header file.

    An inline member function can be defined in two ways:

    • Define the member function in the class body itself.
    • Declare the member function just like a normal member function inside the class but when you define the inline member function, prepend the member function’s definition with the keyword inline and put the definition into a header file, like the following:
    
    class ClassA
    {
    public:
        void f();
    };
    
    inline void ClassA::f()
    {
    }
    

    If you put the inline function’s definition into a .cpp file and it if it is called from some other .cpp file, you’ll get an “unresolved external” error (C++ FAQ Lite) from the linker.

    I don’t think it has something to do with the exception being thrown though. I could replicate this problem in Visual C++ 2005 even if the exception is not thrown.

    My guess is that it was trying to inline the function but couldn’t find its definition, since it was on a separate .cpp file. The compiler probably made some special processing because it recognized the inline keyword in the definition. If you remove the inline keyword, the problem disappears and linking is successful. Therefore, you need to place the definition together with its declaration in the header file, if you want it to be treated as inline.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to locate this function call myFooBar() that is referenced inline in some
I'm trying to force inline a member function and I get the error: a_class::mem_func(),
I am trying to use jqgrid inline edit function. But I got the whole
I've been trying to understand what that really means : inline function In C++,
I am trying to pass one variable to a jQuery function inline (i.e.: using
I'm trying to add an inline formset to a form. Here's the minimal code
I'm trying to display an inline dialog (that is, aui-inline-dialog, not aui-dialog) in my
I am trying to understand this inline assembly code which comes from _hypercall0 here
I am trying to make LLVM inline a function from a library. I have
I'm trying to call a function in the onclick event of the button that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.