1

I was exploring famous OBS Studio source code. That is using one git sub-module at
https://github.com/obsproject/libdshowcapture

In the file source/capture-filter.hpp there is a forward declaration of a class which is nowhere defined and used in whole repo and whole OBS-Studio repo.

namespace DShow {

// some other declaration

// this class is nowhere defined and used
class CaptureSource;

//some other declaration and definitions
}

I checked carefully but did not find any definition nor usage of CaptureSource class. If I am right then what can be purpose of such declaration?

Alok
  • 7,734
  • 8
  • 55
  • 100
  • If you are right, than this is unused declaration, which serves no purpose. – SergeyA Jan 22 '21 at 15:10
  • @FrançoisAndrieux if there is no usage of `CaptureSource` class in the library, it's definition in the header is completely useless. – SergeyA Jan 22 '21 at 15:11
  • @SergeyA I missed that it was also unused. I understood it to simply be undefined. – François Andrieux Jan 22 '21 at 15:13
  • 3
    It was most likely useful seven years ago, when that code was written, but the surrounding code has changed since then. Since it's not an error to never use a forward-declared class, it's very easy to leave behind. – molbdnilo Jan 22 '21 at 15:13
  • this is very famous project I dont think it would be really a unused class – Alok Jan 22 '21 at 15:14
  • 1
    @AlokSinghMahor _"famous project"_ really does not guarantee good quality of the code ;-) – Daniel Langr Jan 22 '21 at 15:17
  • The only use case I'm aware of for using a forward declaration that is not defined is as a discriminator tag in a template. Like `using Address_type = NamedType;` where the *in situ* `struct Address_tag` is a forward declaration. – Eljay Jan 22 '21 at 15:18
  • @GuillaumeRacicot I have mentioned in question that its not defined nor used anywhere in the whole project. – Alok Jan 22 '21 at 15:18
  • Maybe file an issue on the github page to see why it still exists. I did verify from a search that it was never used. Edit: I see the issue tab does not exist. I assume there is some way to notify the developers on this project. – drescherjm Jan 22 '21 at 15:20
  • i don't quite understand the question. If you know that it isnt used anywhere, then it isnt used anywhere, aka it has no purpose – 463035818_is_not_an_ai Jan 22 '21 at 15:24
  • @largest_prime_is_463035818 I am assuming that its a famous high quality project so I dont think its really a unused class. May be there would be some purpose that I am trying to find out. – Alok Jan 22 '21 at 15:26
  • 1
    I think we understood that now. Please consider that this project is maybe not as famous as you think, and even if it was having such an artifact as leftover from past refactoring can happen even in the most clean projects – 463035818_is_not_an_ai Jan 22 '21 at 15:28
  • 2
    @AlokSinghMahor All projects of a non-trivial size and age contain code that no longer serves any purpose. They also contain misleading comments and code that is not as good as it could be. And bugs. – molbdnilo Jan 22 '21 at 15:29
  • 1
    ^^ this and if you have to choose what to fix then you usually choose bugs ;) – 463035818_is_not_an_ai Jan 22 '21 at 15:40

0 Answers0