Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#include <> and #include "" [duplicate]

Possible Duplicate:
what is the difference between #include <filename> and #include “filename”

Is there a fundamental difference between the two #include syntax, apart from the way the path the compiler will search for?

I have the feeling that Intel's compiler does not give exactly the same output.

like image 848
fulmicoton Avatar asked Sep 02 '09 12:09

fulmicoton


2 Answers

The fundamental difference is in which paths are searched.

You're supposed to use the angle bracket form for "system" includes, and regular quotes for project-local includes.

like image 198
unwind Avatar answered Oct 17 '22 03:10

unwind


The C language standard says that <> is to be used for "headers" and "" is to be used for "source files". Now, don't get all up in arms about the "source files" thing. When the standard says "source files", it doesn't mean what you think. The term "source files" as used in the standard encompasses what we colloquially call "header files" (in addition to what we commonly call "source files").

When the standard talks about "headers", it isn't specifically talking about files at all. The standard does not require headers to exist as files. They could be built-in to the compiler for all the standard cares.

So the real difference between <> and "" is that <> is used for headers and "" is used for files. If you know that the source you'll be including is a file then you should use "".

In practice, compilers use different search algorithms for <> versus "". This is allowed by the standard as the search algorithm to be used for either one is implementation defined. But this is not the real difference as expressed by the standard.

like image 22
Dan Moulding Avatar answered Oct 17 '22 05:10

Dan Moulding