I wish there was a way to split a #include directive across two lines, so that my code can conform to 80 characters per line, despite the necessity of a very long include path.
Other than expanding the search path of the compiler, how can I manage this? Is there a way to split my very long path string into two lines?
"#define" macro expansion apparently happens after #include expansion, so these don't work:
#define BIGPATH "..."
#include BIGPATH ## "/foo.c"
#include "BIGPATH/foo.c"
#include BIGPATH"/foo.c"
I've also tried
#include "foo" ##
"bar"
and
#include "foo" \
"bar"
To no avail. Perhaps what I want is impossible? Help me, stackoverflow kenobi, you're my only hope.
ANSWER: building on the suggested answer below, here's what actually worked for me:
#define STRINGIFY(x) #x
#define PATH(path) STRINGIFY(/my/very/long/path)
#include PATH(foo.h)
#undef PATH
#undef STRINGIFY
Splitting up your long run not only allows you to complete your mileage, but it can help you run with better form throughout the distance. We all have a fatigue threshold at which our endurance ability fades and our form starts to deteriorate.
The (Almost) Long Run Long runs are damaging, both physically and mentally. Without recovery, you'll never absorb their training benefits and boost your endurance. This is why most runners never do two long runs in a single week.
The 10/10/10 approach to the marathon calls for splitting the race into three separate sections: the first 10 miles, the second 10 miles, and the final 10K.
“Chunking” is a mental strategy in which a person mentally subdivides a tasks into smaller components. The most common method in running is to break up a run into shorter distances.
I do not like the idea of this, I just wanted to mention this possibility. The best is to go the way Daniel Fischer mentioned. This solution is a bit quirky and will not work under all circumstances but this compiled here:
#define PATH(FILE) </path/to/FILE>
#include PATH(file.h)
And just to name some of the obvious limitations:
Feel free to add to this list.
Edit
Just for better readability I will post the solution from Jonathans comment below in the style of my example:
#define STRINGIFY(x) #x
#define PATH(FILE) STRINGIFY(/path/to/FILE)
#include PATH(foo.h)
This version mitigates the "locality problem" of the #include <>
version, as it maps to #include ""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With