What does "#pragma hdrstop" do?

Started by
1 comment, last by gunne 22 years, 4 months ago
Title says it all...
Advertisement
Click on it and hit F1. It''s in the doc.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
In C++ Builder, #pragma hdrstop instructs the preprocessor that it shouldn''t generate precompiled headers for any #included files after that point.

Precompiled headers speed up compilation by reducing the time it takes to read and parse the header files. This is of particular interest for things like <windows.h>, which are very large.

It seems that rather than generating a precompiled form of each header, C++ Builder will precompile all the headers used in a .cpp file up until #pragma hdrstop. This means that if you include different headers in each file, C++ Builder will precompile each set of headers seperately, even those headers that are included in all files.

The best solution is to do this at the top of each file:

  #include <windows.h>#include <vcl.h>#include ... whatever else you need ...#pragma hdrstop  


Assuming this is the same at the start of every file, the headers will be precompiled only once, making everything faster. Unfortunately, #pragma hdrstop only does its stuff in .cpp files, and not .h files.

There''s an article about it here.

Abolish Software Patents! | freepatents | lpf
CoV

This topic is closed to new replies.

Advertisement