Question

Can the VC compiler warn if it cannot find an implementation of a prototype?

Example (notice mismatching params):

// calcSomething.h
int calcSomething(
    int    year,
    int    month,
    int    day,
    int    hour,
    int    minute,
    int    second
);

and

// calcSomething.cpp
int calcSomething(
    int    year,
    int    month,
    int    day
) 
{
  // ... implementation
}

Update: Apparently G++ has a switch called -Wmissing-declarations which I think might be along the lines of what I need, but obviously for VC++.

Was it helpful?

Solution

It appears the answer is no. The MSVC compiler does not have an option equivalent to G++'s -Wmissing-declarations.

Command line options by category.

OTHER TIPS

These two are totally different functions, according to the C++ language rules.

The compiler should react in the same way as if the name of the first function was calcSomething and the name of the second one was calcSomeOtherThing.

In particular, the function you declared in the header will be undefined, since it has no implementation. Any code which calls it will not compile and link. It is not possible to make an executable which calls a function which was never defined. The compiler doesn't know what to do when the function is called.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top