伊莉討論區

標題: problem in C language write .txt [打印本頁]

作者: cwfw    時間: 2012-4-2 03:34 PM     標題: problem in C language write .txt

please read the code:

when I ready try to generate a .hex file for this code, the system said 'FILE' and 'fp' are undefined identifier. Do anyone know what happen?

作者: Invi6666    時間: 2012-4-2 10:34 PM

提示: 作者被禁止或刪除 內容自動屏蔽
作者: cwfw    時間: 2012-4-3 05:46 AM

Invi6666 發表於 2012-4-2 10:34 PM
What compiler you use? I don't have any problem after compiled your program

Keil uVision2

I use this to generate a .hex file.
作者: mp0801    時間: 2012-4-3 06:56 AM

I think Keil uVision2 is not support FILE function. You need ensure keil c library
have FILE function and include it.
作者: cwfw    時間: 2012-4-3 06:34 PM

mp0801 發表於 2012-4-3 06:56 AM
I think Keil uVision2 is not support FILE function. You need ensure keil c library
have FILE functio ...

I am sorry, can you tell me more. Do I need to include some library or use other command?

補充內容 (2012-4-3 06:36 PM):
what library do I miss?
作者: mp0801    時間: 2012-4-3 09:03 PM

Keil C is support embedded system platform. Just like 8051, ARM ......
It c library is not same with computer C(GCC).
Keil C have not all C(GCC) library function.
You use FILE maybe include <stdio.h>, but Keil C <stdio.h>  must have FILE function.
I remember Keil C is not support FILE function.
If you want create HEX file, you can try computer C platform.(window,linux,...)
作者: cwfw    時間: 2012-4-4 05:11 PM

mp0801 發表於 2012-4-3 09:03 PM
Keil C is support embedded system platform. Just like 8051, ARM ......
It c library is not same with ...

sorry, don't understand.
computer C plarform?
you mean using keil C in linux or what???????
can window 7 ok?
作者: EdisonX    時間: 2012-4-5 03:27 AM

cwfw 發表於 2012-4-4 05:11 PM
sorry, don't understand.
computer C plarform?
you mean using keil C in linux or what???????

what reason makes you to use keil C ?
作者: mp0801    時間: 2012-4-5 06:37 AM

window 7 is OK, and I design some thing for embedded system.
So I have some experience for using Keil C
作者: cwfw    時間: 2012-4-5 08:07 AM

EdisonX 發表於 2012-4-5 03:27 AM
what reason makes you to use keil C ?

it's one part of my project actually.
作者: EdisonX    時間: 2012-4-5 04:22 PM

execute me, can I answer those in Chinese ? Orz

I don't know why using file stream instructions in embedded system ,
but I think this action is not rational.

FILE struct is defined in <stdio.h> header
but Keil C has no this header, the reason as below description.

Microprocessor is not personal computer (PC).
Is there any disc on the system ?

If not, it means there is no disc, no operation system, no document system.
how can we expect that , Keil C has file stream instructions ?

finally, sorry for my poor English.
作者: cwfw    時間: 2012-4-5 04:57 PM

EdisonX 發表於 2012-4-5 04:22 PM
execute me, can I answer those in Chinese ? Orz

I don't know why using file stream instructions in  ...

you can answer in english, of course.
are you saying that even the full version of keil C have no this header?
作者: mp0801    時間: 2012-4-5 06:19 PM

Yes or No ? Actually, Keil C is not support file system, but I think you
can search third party distribution. Maybe you can find it or write a
new FILE function for yourself.


作者: EdisonX    時間: 2012-4-5 07:00 PM

As mp0801 said,
" Keil C is not support file system " ,
even the full version of keil C  has no those instructions ( or header ) .
作者: cwfw    時間: 2012-4-9 01:07 PM

mp0801 發表於 2012-4-5 06:19 PM
Yes or No ? Actually, Keil C is not support file system, but I think you
can search third party dist ...

I am sorry, you can answer in Chinese.
I want to ask what if I write the data to excel? will it work? because my project must use keli C, so I must find a way to store the data, in txt or in excel is ok.

補充內容 (2012-4-9 01:18 PM):
can I use other code besides the "FILE*fopen" to do so?
作者: cwfw    時間: 2012-4-9 01:17 PM

EdisonX 發表於 2012-4-5 07:00 PM
As mp0801 said,
" Keil C is not support file system " ,
even the full version of keil C  has no th ...

I am sorry, you can answer in Chinese.
I want to ask what if I write the data to excel? will it work? because my project must use keli C, so I must find a way to store the data, in txt or in excel is ok.

補充內容 (2012-4-9 01:18 PM):
can I use other code besides "FILE*fopen" to do so?
作者: EdisonX    時間: 2012-4-9 06:12 PM

我以中文方式把上述的結論述敘一遍。

8051 / ARM 這些 MicroProcessor ,在他們本身的硬體架構裡面,找不到任何與硬碟有關的硬體,更遑論「檔案系統」之既念,故正常而言,Keil-C 並不附關於 file stream 相關函式也是可以理解的。

當然你說的 excel 本身也是一種檔案,以自己的格式方式存入而已,所以基本上這行為是辦不到的。另外用 FILE * 方式開啟 excel 讀取數值基本上需要費相當大的功夫,通常都是使用其他 IDE ,套用 COM componment 概念下去解,這更是不可能完成的事。 (另希望你說的是 csv 檔,而不是 .xls(x) 檔)

而 mp0801 版友所言之方式,我認為應是找尋是否有廠商,專門為 Keil C 開發 file stream 之相關 library,但這前提也必須是:整個硬體系統要包含了硬碟 (基本上認為這前提不怎麼可能發生...)。

我不知究竟有什麼苦衷一定要用 Keil-C 讀檔,但我認為或許要做的,是讀取 ROM value,可能較為合理。

有誤請指正。
作者: mp0801    時間: 2012-4-9 06:21 PM

^^ maybe my English is not good.
below is my suggest.
KEIL C中沒有FILE的實作,造成無法建立出對應WINDOWS系統的檔案結構
雖然TXT只是一般的文字檔,但沒檔案結構依然無法讓系統存取,因為WINDOWS
必須要有對應的檔案結構才能存取資料,不然看起來只是一堆二進位資料.
若你要在KEIL C下建立檔案也可以考慮植入作業系統來建立相對應的平台,但
我想這似乎又有一點小題大作.
以上是我個人見解,提供你參考,或許還有其人有更好的答案.
另外你也可以提供你要實作的真正需求,或許可以提供你最佳解.





歡迎光臨 伊莉討論區 (http://a401.file-static.com/) Powered by Discuz!