header1.h:
1 2 3
|
// This is a header
void foo();
// The last line is a comment without a new line
|
header2.h
main.cpp
1 2
|
#include "header1.h" "header2.h"
int main() {foo(); bar();}
|
Supposing for a moment that there were
ANY value to writing short code, how would the above work?
Because #included files are pasted into the source files, the declaration of bar would be appended to the end of the first file included, effectively putting it at the end of the single-line comment. There would be no declaration of bar(), and the code would not compile.
Writing obfuscated code is what was done 40 years ago. Back then, storage was expensive and compiler optimizations were poor. Tricks to shorten code were encouraged.
But now it is accepted that verbose code with lots of appropriate white space, formatting and good comments is easier to maintain and cheaper and better in the long run.
There are old books of obfuscated code samples that are essentially puzzles: "what does this do?" They are amusements but should never be used in live code because, when reviewing it-or worse, when maintaining it-the time to figure out what the code does is longer that the time it would have taken to write it cleanly and verbosely in the first place.
So, why again are individual lines of #includes so vile that you need to combine them into 1?