What can you do in C without “std” includes? Are they part of “C,” or just libraries?

后端 未结 11 1014
孤独总比滥情好
孤独总比滥情好 2021-02-02 06:11

I apologize if this is a subjective or repeated question. It\'s sort of awkward to search for, so I wasn\'t sure what terms to include.

What I\'d like to know is what th

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-02 06:40

    You're certainly not obligated to use the standard libraries if you have no need for them. Quite a few embedded systems either have no standard library support or can't use it for one reason or another. The standard even specifically talks about implementations with no library support, C99 standard 5.1.2.1 "Freestanding environment":

    In a freestanding environment (in which C program execution may take place without any benefit of an operating system), the name and type of the function called at program startup are implementation-defined. Any library facilities available to a freestanding program, other than the minimal set required by clause 4, are implementation-defined.

    The headers required by C99 to be available in a freestanding implemenation are , , , , , , and . These headers define only types and macros so there's no need for a function library to support them.

    Without the standard library, you're entire reliant on your own code, any non-standard libraries that might be available to you, and any operating system system calls that you might be able to interface to (which might be considered non-standard library calls). Quite possibly you'd have to have your C program call assembly routines to interface to devices and/or whatever operating system might be on the platform.

提交回复
热议问题