Why use precompiled headers (C/C++)?

后端 未结 5 466
傲寒
傲寒 2020-12-01 01:00

Why use precompiled headers?


Reading the responses, I suspect what I\'ve been doing with them is kind of stupid:

#pragma once

// Defines used         


        
5条回答
  •  孤街浪徒
    2020-12-01 01:18

    Re: your current usage, if you have a target with a very large number of files, it may still be faster to use PCH in that way - try switching them off to find out. It depends: if you have a lot of headers of your own, and you change them only infrequently, and you have a very large number of source files that you change much more frequently, then your PCH usage will cut rebuild times.

    But normal advice is to only put things in PCH that never change, because there is a certain overhead to producing the PCH itself. If you trigger that off with every rebuild (by constantly tweaking one of your headers), using PCH may make the rebuild slower.

提交回复
热议问题