0

Suppose I am working on a library with a decent number of classes, most of them having a bunch of methods, in addition to the basic ctors and dtor. For reasons, the method implementations are spread across different files, and IDEs tend to fail to detect where the implementation of a method actually is, so that "Go to definition" / "go to declaration" is hit-and-miss, or mostly-miss.

Now, I'm in the middle of work, so not all methods have been implemented. Eventually, in the future, I will have test coverage for every method, and so they will all have to be implemented so as to link succesfully; but for now - there are only a few test programs which don't cover the full range of methods, and those manage to link and run.

I want to be able to determine, for a given method declared in a class, whether it's implemented or not in the library's source code repository, and/or obtain a list of all unimplemented methods.

How would I go about doing that?

Notes:

  • Obviously, if I write code which uses a method and link it, that will determine whether it's defined or not. The point is not to have to do that.
  • Assume I have a modern GNU/Linux distribution and relevant packages installed. A Windows-specific answer is legitimate but less desirable.
  • This question is similar, except that in that case, there are executables failing to link. Also, it was asked 12 years, is constained
  • If you would like additional information regarding why the IDE can't discern between implemented and unimplemented methods, please ask in the comments. I'm using CLion 2025.1, although I'm not banking on answers based on my IDE.
18
  • The obvious solution would be to just create an executable that tries to call the methods in question, then it will fail to link if it's not implemented, but I guess you don't want to do that. You can also mark these methods as virtual, then you will get undefined reference to vtable if you ever try to create an object of the class in question, without calling that method. Commented Aug 1 at 10:49
  • 1
    @463035818_is_not_an_ai Just removing -O3 also helps. Commented Aug 1 at 11:05
  • 1
    That is a tricky problem. I don't know of any tools that would provide you a list of declared functions that have no definition. And if the function is never called by any other code, the linker won't complain about it missing. (My team uses a void foo() { throw unimplemented_error{}; } convention, but that's just a convention.) Commented Aug 1 at 11:27
  • 1
    Can't you build your library as a dynamic library with --no-undefined option? Commented Aug 1 at 11:46
  • 2
    Re: "Eventually, in the future, I will have test coverage for every method" -- don't wait; do it now. Commented Aug 1 at 14:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.