This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/CC2640R2F: __inline directive results in linker error

Part Number: CC2640R2F

Tool/software: TI C/C++ Compiler

Hi,

I found out if I use the __inline directive for a method in my C++ class it results in a linker error.

How should I use the __inline directive correctly?

Code:

__inline StdError DeviceDiscovery::addDevice ( BLE::Device &device )
{
...
}

LInker output:

<Linking>
 
 undefined                                              first referenced
  symbol                                                    in file     
 ---------                                              ----------------
 Application::DeviceDiscovery::addDevice(BLE::Device &) <whole-program> 
 
error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking

  • The general rule for inline functions is to make sure the caller can see the source of the inline callee. I'd guess that your definition is in a .cpp file and it's being called from another .cpp file, which means it can't see the definition. Try putting the definition in a .h file that is included by all calling files, such as the .h file that defines the class.

    If that doesn't fix your problem, then we'll need to see more detail about your program, such as a small example that fails, so we can give you a better answer.
  • Please let us know whether the suggestion from pf worked.

    Thanks and regards,

    -George

  • Hi George,
    sorry for my late reply.

    It seems that it does work with some methods if the __inline directive is placed in the header, but in those cases the code compiles as well if the same directive is add only in the CPP file.

    However with the method I posted above it does not work at all. Neither defining it in the cpp file nore in the header file works.

    Probably a speciality of this method is, that it is a method which is once defined in a base class and a second time in a derived class of the base class. So the method is shadowing another method I don't know if that matters?

    For now I just don't use it but for the future it would be interesting to find out what is the cause of this problem!.

    kind regards
    Andreas
  • Is it practical for you to create a CCS project which, when built, exhibits the linker error diagnostic you show in your first post?  If so, please package up that project as described in the article Sharing Projects, then attach it to your next post.

    Thanks and regards,

    -George

  • Hi George,

    if I have time left for it I can try to make such a project. At the moment I have to dig into other things.

    I hope I can provide you with such code in a few weeks.

    kind regards

    Andreas

  • I would appreciate whatever you can do to help us understand what happened.

    Since it will be a while before you can respond, I'll mark this thread as resolved.  Even though that is not quite the case.  When you reply, the thread will automatically re-open, and I'll be notified.  However, this thread automatically locks after 30 days.  If that happens, then I am afraid you have no choice but to start a new thread.

    Thanks and regards,

    -George