Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would one use #include_next in a project?

To quote the iOS Documentation on Wrapper Headers:

#include_next does not distinguish between <file> and "file" inclusion, nor does it check that the file you specify has the same name as the current file. It simply looks for the file named, starting with the directory in the search path after the one where the current file was found.

The use of `#include_next' can lead to great confusion. We recommend it be used only when there is no other alternative. In particular, it should not be used in the headers belonging to a specific program; it should be used only to make global corrections along the lines of fixincludes.

So, two questions, what is #include_next, and why would you ever need to use it?

like image 444
CodaFi Avatar asked Apr 21 '12 17:04

CodaFi


People also ask

Why is would use?

would is the past tense form of will. Because it is a past tense, it is used: to talk about the past. to talk about hypotheses (when we imagine something)

Why would or should I?

Use "should" to say that something is the right thing to do; use "would" to talk about a situation that is possible or imagined. So, add another modal, such as "could," to the sentence to see if it still makes sense. For example, you could say: Joe "should" call his mom this week.


1 Answers

It is used if you want to replace a default header with one of your own making, for example, let's say you want to replace "stdlib.h". You would create a file called stdlib.h in your project, and that would be included instead of the default header.

#include_next is used if you want to add some stuff to stdlib.h rather than replace it entirely. You create a new file called stdlib.h containing:

#include_next "stdlib.h" int mystdlibfunc(); 

And the compiler will not include your stdlib.h again recursively, as would be the case with plain a #include, but rather continue in other directories for a file named "stdlib.h".

like image 112
Hampus Nilsson Avatar answered Oct 20 '22 18:10

Hampus Nilsson