2 ms·
Which compiler parses the same header file multiple times in the same translation unit? Compilers have been optimizing around pragma once and header guards for
by gpderetta 3y ago
Which compiler parses the same header file multiple times in the same translation unit? Compilers have been optimizing around pragma once and header guards for multiple decades.
edit: ok, you meant that each header is included once in each translation unit.
- josephg 3y agoYep. Worst case, every header is included in every translation unit. Assuming you have a similar proportion of code in your headers and source files, compilation time will land somewhere between O(n) and O(n^2) where n = the number of files. IME in large projects its usually closer to n^2 than n. (Technically big-O notation specifically refers to worst case performance - but thats not how most people use the notation.)