Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How C language data types are supported by most computer systems

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about how the C language data type is supported by most computer systems, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following for you. I hope you can get something from this article.

Question:

When I was reading the book The C Programming Language, I saw this note in [introduction, page 3]:

Because the data types and control structures provided by C language can be directly supported by most computer systems, the runtime files needed to implement self-contained programs are generally very small.

What does this boldface mean? Can you find an example to show that a certain data type or control structure in C language is not directly supported by a certain computer system?

Answer:

In fact, there are data types in C that are not directly supported.

In many embedded systems, there is no floating point unit on hardware. So, if you write the following code:

Float x = 1.0F, y = 2.0f

Return x + y

It may be transformed into the following form:

Unsigned x = 0x3f800000, y = 0x40000000

Return _ float_add (x, y)

Then the compiler or standard library must provide a concrete implementation of 'floatadd ()', which takes up the memory space of the embedded system. If you use this to calculate the actual number of bytes of code in a micro system, you will also find an increase.

Another common example is 64-bit integers (the 'long long' type' in the C language standard only appeared after 1999), which cannot be used directly on 32-bit systems. Antique SPARC systems do not support integer multiplication, so the implementation of multiplication must be provided at runtime. Of course, there are other examples.

Other languages

Compared with other programming languages, there are more complex basic types.

For example, symbol in Lisp requires a large number of runtime implementation support, such as table in Lua, string in Python, array in Fortran, and so on. Equivalent types in C are usually either not part of the standard library (C does not have a standard symbol or table), or are simpler and do not require that much runtime support (array in C is basically a pointer, and strings ending in NULL are easy to implement).

Control structure

Exception handling is a control structure that does not exist in C language. There are only two types of non-local exits, 'setjmp ()' and 'longjmp ()', which can only save and restore some parts of the processor state. In contrast, the C++ runtime environment must first traverse the function call stack and then call destructors and exception handlers.

After reading the above, do you have any further understanding of how C language data types are supported by most computer systems? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report