Question

I am refactoring a legacy and i need to lean on the compiler for a bit. Some settnig in Visual Studio is not working like i want it to work.

file a.c

int main (int i, char** l)
{
    dostuff(i);
}

file b.h

//empty header

file b.c

void dostuff(int i);


void dostuff(int i)
{
    //bla
}

a.c does not include the b.h nor does b.h meantion dostuff. Since dostuff is not static the symbol is exported. If i delete b.c the compiling fails.

I would like to set up vs2010 so that it generates an error for a.c because the symbol dostuff was not imported via include.

What setting would do that for me?

Was it helpful?

Solution

First of all your code should be generating a warning (at level 3) so you should be able to see that something is wrong after compilation from that. If you want an error:

You can add #pragma warning (error : 4013) in your a.c file.

Alternatively add /we4013 to the additional options under Configuration properties->C/C++->Command Line

This treats the warning generated by your code as an error

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