Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "" and <> when a header file is included in a program? [duplicate]

Tags:

c

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

I would like to know what's the difference between

#include "stdio.h"

and

#include <stdio.h>
like image 695
amin Avatar asked Mar 04 '11 07:03

amin


2 Answers

Use <whatever> for system headers, and "whatever" for your own headers.

The difference is that when it's enclosed in quotes, the compiler will look in the local directory, but with <>, it won't. If you want to get technical, the C standard doesn't guarantee that, but it's how essentially all compilers work.

like image 75
Jerry Coffin Avatar answered Sep 24 '22 23:09

Jerry Coffin


"" searches in current file's path. <> searches in global include paths.

Edit: You asked for absolute path and relative path.

Assume you have a file structure as follows:

folderX
 -fileX.a
 -fileX.b
 -folderX.Y
  -fileX.Y.a
  -fileX.Y.b
 -folderX.Z
  -fileX.Z.a

Then, the absolute path of fileX.Z.a would be folderX/folderX.Z/fileX.Z.a, assuming that folderX is the topmost directory available. The relative path of fileX.Z.a relative to e.g. fileX.a is just the part folderX.Z/fileX.Z.a, i.e. you start the path in the directory where fileX.a lies.

like image 31
phimuemue Avatar answered Sep 21 '22 23:09

phimuemue