Ned
Ned

Reputation: 293

Faster builds by turning off all warnings?

I'm currently using Visual Studio for work builds. Say I'm not interested in any possible warnings--warnings and errors are dealt with on a different repository with a different team, etc. I just need to get the code, build it as quickly as possible, and run it.

Will it be faster if all warnings are turned off?

In Visual Studio, this is Off: Turn Off All Warnings (/W0)

I think GCC and other compilers have similar options.

I've wondered this a while, and could never find anyone asking the same question. Or the search string always found other questions with 'warnings' in it. I thought I'd ask in case anyone else ever wondered this.

Edit: It occurred to me that maybe others might think this is a dumb question. The reason I thought it was possible that turning off warnings could speed build time, was maybe it would prevent some warning-checking compile code from running, saving time. But if the warnings are always being checked for behind the scenes anyway, and it's just the printing of them that differs with warning level, then it is not much of an increase, unless you have tons and tons of warnings.

Upvotes: 1

Views: 527

Answers (2)

Non-maskable Interrupt
Non-maskable Interrupt

Reputation: 3911

Since you mentioned gcc, the properly way for gcc to reduce compile time is to generate (and use) dependency file with -MMD -MP switch, so unnecessary re-compilation are skipped.

For Visual Studio, the next best thing is to enable incremental build, however keep in mind it sometime mess up for no reason.

Upvotes: 1

Thomas Matthews
Thomas Matthews

Reputation: 57688

Yes, turning off warnings will speed up the build process since the compiler does not have to perform printing. Printing (displaying the text) takes time.

The question for the OP, is: Is the time difference between printing with warnings on vs. printing without warnings negligible?

IMHO, unless the speed difference is in terms of tens of minutes, I find printing of warnings a good thing. Any time savings under ten minutes is wasted during the day by unexpected meetings, unexpected conferences with colleagues or other overhead.

However, the cost of ignoring warnings may be higher than any profit gain by speeding up the build process.

Upvotes: 3

Related Questions