Linux under C programming, include default search path

Source: Internet
Author: User

when programming in C language, it is very attractive to find details. A more detailed look at a bit about the knowledge of include, found a few things:

1.include< header file name > and include "header file name"

such as:include<stdio.h> and include "Stdio.h"

The former (using <>), to refer to the Stdio.h file, is to first retrieve the standard path to see if there is a header file under these folders, and if not, it will not retrieve the current file path, and will error.

The latter (using ""), to refer to the Stdio.h file, is the first to retrieve the current path of the file, and if not, retrieve the standard path to see if there is a header file under those folders.

2.linux, the above standard path is:/usr/include,/usr/local/include.

3.<sys/header file name >. such as <sys/io.h>,<net/ethernet.h> and so on. where the preceding string (such as Sys,net) represents the folder name under the standard path, followed by a string (such as io.h,ethernet.h) that represents the header file name under each folder under the Linux standard path, such as the io.h file under the Sys folder, which we can/usr/ IO.h file found in the Include/sys directory.

Linux is profound and needs to accumulate slowly.

4. If you want to retrieve the header file under the specified path, you can add option-I. As in my/home/desktop directory, there is a header file Local1.h, which is available when compiling test.c files containing local1.h: gcc test.c-o test-i/root/desktop.

Linux under C programming, include default search path

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.