|
|||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng) 驅(qū)動編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機 | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計 | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe |
Keil 官方技術(shù)支持集<絕對經(jīng)典> |
| 作者:leeding 欄目:單片機 |
包含了使用Keil的方方面面的問題. 這里資料怎么上傳。? 如: C51: '\N' DOES NOT WORK IN PRINTF() STATEMENTS -------------------------------------------------------------------------------- Information in this SUPPORT solution applies to: C51 Version 5.50 C51 Version 6.00 Beta C51 Version 6.00 -------------------------------------------------------------------------------- SYMPTOMS It appears that my \n does not work in printf() statements. When I view the OUTPUT on a DUMB terminal, I do not see a carriage return-LINE feed. For example: printf("hello world\n"); The above statement does not appear to send the '\n'. Instead, I have to use this to make it work: printf("hello world"); putchar(CR); Why does this happen? What is printf doing to the '\n'? CAUSE In most C compilers, including ours, the newLINE escape sequence '\n' yields an ASCII LINE feed character. The C escape sequence for a carriage return is '\r'. When you create C programs in what the C STANDARD calls a "hosted implementation" (where the programs run under an operating SYSTEM), the operating SYSTEM or the stdio library routines are supposed to convert the newLINE character to whatever it takes to actually go to the beginning of the next LINE, e.g., carriage return + LINE feed. For a "freestanding implementation" (where the programs run without any operating SYSTEM), the STANDARD doesn't specify any requirements for library routines. It is up to the compiler vendor to decide what library routines to provide, and how each should work. All Keil compilers are freestanding implementations of C. Users of our compilers send the OUTPUT from printf() to a variety of devices with different requirements for MARKING the end of a LINE. So, any method we might choose to handle '\n' would be wrong in many cases. On OUTPUT, the default version of our library routine putchar() handles newLINE characters by OUTPUTting a carriage return and a LINE feed. Many projects require a user-written version of putchar(). If your project has a CUSTOM putchar() function, it may handle newLINE characters differently. For example, it may pass all characters through with no special-case treatment for '\n' (LINE feed). RESOLUTION There are three different ways to solve this problem: Include a '\r' along with (or perhaps instead of) the '\n' in OUTPUT strings. printf("Hello world\r\n"); Modify the putchar() function such that when it is called to OUTPUT a LINE feed, it OUTPUTs a carriage return in addition to the LINE feed. Use a terminal that will treat a LINE feed character as a newLINE character (i.e., as a carriage return and LINE feed). -------------------------------------------------------------------------------- Last Reviewed: 5/26/2000 COPYRIGHT (c) 1996-1999 Keil SOFTWARE, Inc. All rights reserved. |
| 2樓: | >>參與討論 |
| 作者: john_light 于 2005/12/13 10:21:00 發(fā)布:
到這里,更全更新 http://www.keil.com/search.asp 你說的那個文件應(yīng)該是keil的光盤上帶的support.chm。 |
|
|
|
| 免費注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點此進入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號 |