Use the printf () function with caution in the New Tang cortex-m051-A printf () function 4 kb size

Source: Internet
Author: User

Recently, When I encountered a problem in the integrated project, I did not pay attention to it at first, but then I found out that it was myProgramI can't burn it into the chip, after checking the manual, I found that the flash of the New Tang cortex-m051 is only 8 KB, after my program is compiled, the binfile actually has 16 KB, my program has only over 1300 lines of comments. How can it be so big?

 

I don't know what the problem is, so I began to cut down the program and delete some programs that can be desired or not (that is, some parts that will be more humane after the program is required ), some strange things happened when I deleted four printf files and reduced the number of binfiles from 16 KB to 13 KB. So I deleted all printf files, the program is reduced to 11 kb. Later, in a very small program, a printf function call exceeded 4 kb of space.

 

As a function makes my program so much bigger, I'm curious, so I went to look at the prototype of this function, in the New Tang cortex-m0 in the end how to encapsulate, unfortunately, I did not find it, so I did not care about other programs. on July 15, December 16, the New Tang dynasty will come to Nanjing for a lecture tour. Then I will ask them clearly, I will share the answer with you later.

 

For embedded programming, the space of each byte is so precious. I hope you can use printf with caution during programming. Although this function is really convenient, it is not enough space, you can use send_to_pc () in the UART function provided by the system to send a byte to the computer through the serial port.

 

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.