Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-I dir vs. -isystem dir

Tags:

c

gcc

If I want to include directories to be searched for header files, which is the preferred way and why?

like image 331
helpermethod Avatar asked Apr 05 '10 16:04

helpermethod


People also ask

Why do we use DIR?

Purpose: Displays directory of files and directories stored on disk. In addition to files and directories, DIR also displays both the volume name and amount of free storage space on the disk (if there are files stored in the current directory).

What is console DIR vs Consolelog?

The console method log() displays the toString representation of any object passed to it. The Console method dir() displays an interactive list of the properties of the specified JavaScript object.

What is console DIR () in JavaScript?

dir() The method console. dir() displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.

What does DIR stand for in console DIR?

It just means "Directory". Directory is a synonym for index, list, listing, register, catalogue, record, archive, inventory etc.


2 Answers

One way to view this is to use headers that you control with -I and the ones you don't (system, 3rd party libs) with -isystem. The practical difference comes when warnings are enabled in that warnings which come from -isystem headers will be suppressed.

like image 182
Laurynas Biveinis Avatar answered Oct 14 '22 13:10

Laurynas Biveinis


From the gcc documentation for -I:

Add the directory dir to the head of the list of directories to be searched for header files. This can be used to override a system header file, substituting your own version, since these directories are searched before the system header file directories. However, you should not use this option to add directories that contain vendor-supplied system header files (use -isystem for that). If you use more than one -I option, the directories are scanned in left-to-right order; the standard system directories come after.

If a standard system include directory, or a directory specified with -isystem, is also specified with -I, the -I option will be ignored. The directory will still be searched but as a system directory at its normal position in the system include chain. This is to ensure that GCC's procedure to fix buggy system headers and the ordering for the include_next directive are not inadvertently changed. If you really need to change the search order for system directories, use the -nostdinc and/or -isystem options.

So -I is probably the preferred option to specify the location of your header files, except for special cases such as vendor-supplied system headers.

like image 43
Justin Ethier Avatar answered Oct 14 '22 12:10

Justin Ethier