0

I am wondering if there are any compiler flags you can set to pick up this case. Say I have the following files:

a.h

class a
{
    public:
    int lala(void);
    int lala2(void);
};

a.cpp

#include "a.h"

int a::lala(void)
{
    return 5;
}

main.cpp

#include <iostream>
#include "a.h"

int main()
{
    a thi;
    std::cout << thi.lala() << std::endl;
    return 0;
}

The problem here is that the function lala2 is not implemented and although its not used not even a warning is issued.

So i don't know how it led to this but basically in a large portion of code there was an un-implemented function. I am just wondering if there are any compiler flags that will allow us to pick this up? Using g++ -pedantic -Wall was not enough.

Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175

1 Answers1

0

The compiler can't do that. The compiler compiles source files one by one. You may have the implementation of lala in one source file and of lala2 in another. The compiler has no way of knowing whether there's a lala2 implementation somewhere else.

The linker will display an error if you try to use lala2. If you don't, the code will just work.

zmbq
  • 38,013
  • 14
  • 101
  • 171