symbol was eliminated by linker Delphi7编译器错误 |
答題得分者是:pcboy
|
waytounknow
一般會員 發表:4 回覆:7 積分:2 註冊:2007-08-11 發送簡訊給我 |
各位大大,最近我通过delphi7定义了一个函数GetFilePath;目的是为了从INi配置文件中读取一个保存文件的路径。函数定义如下:
function GetFilePath(iniFileName,sSection,sIndent: string):string; function TForm1.GetFilePath(iniFileName,sSection, sIndent: string): string; var IniFile : TInIFile; begin IniFile := TIniFile.Create(AppFilePath iniFileNames); try Result := IniFile.ReadString(sSection,sIndent,''); finally IniFile.Free; end; end; 然后我通过一个按钮时间调用这个函数 var FilePath:string; begin FilePath := GetFilePath('hm2_report','report_path'); end; 在调试时,我发现函数GetFilePath中的第一个参数iniFileNames给出错误信息,Symbol was eblimimated by linker。IniFileName不是delphi的保留字啊,怎么会出现这样的错误? 烦请路过的高手帮俺看一下,谢了。
------
My way .... way to unknow |
pcboy
版主 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
我不是高手, 請問您有把Bug盡量除盡再貼出來嗎? 還是留一堆bug讓想幫您的人自己處理? ( 或者建議您將整個程式壓縮上傳還比較方便 debug ) 問題1 function GetFilePath(iniFileName,sSection,sIndent: string):string; function TForm1.GetFilePath(iniFileName,sSection, sIndent: string): string; 出現 [Error] Unit1.pas(28): Function needs result type 問題2 FilePath := GetFilePath('hm2_report','report_path'); 出現 [Error] Unit1.pas(48): Not enough actual parameters 只用兩個參數去呼叫需要三個參數的函數 問題3 function TForm1.GetFilePath(iniFileName,sSection, sIndent: string): string; 這裡是 iniFileName IniFile := TIniFile.Create(AppFilePath iniFileNames); 這裡卻是 iniFileNames (多一個s) 問題4 > 然後我通過一個按鈕時間調用這個函數 您到底用 Button 按鈕 ? 或使用 Timer 時間 ?
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案! 子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問! |
pcboy
版主 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
供您參考
[code cpp] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IniFiles; type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; function GetFilePath(iniFileName,sSection, sIndent: string): string; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} function TForm1.GetFilePath(iniFileName,sSection, sIndent: string): string; var IniFile : TInIFile; AppFilePath : String; begin AppFilePath:= extractfilepath(application.exename); IniFile := TIniFile.Create(AppFilePath iniFileName); try Result := IniFile.ReadString(sSection,sIndent,''); finally IniFile.Free; end; end; procedure TForm1.Button1Click(Sender: TObject); var FilePath : String; begin FilePath := GetFilePath('report.ini', 'hm2_report','report_path'); Memo1.Clear; Memo1.Lines.Add(FilePath); end; end. [/code] 其中 report.ini 內容如下 [code cpp] [hm2_report] report_path=d:\report.txt [/code]
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案! 子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問! |
sryang
尊榮會員 發表:39 回覆:762 積分:920 註冊:2002-06-27 發送簡訊給我 |
Symbol was elimimated by linker 不是錯誤
當你設中斷點追蹤程式執行時,若這個變數被 linker 忽略掉, 也就是程式編譯過程中,經過最佳化之後,可以不需要這個變數了,linker 就會視同沒有這個變數 所以,你無法得知這個變數的內容 真要知道也行,把 Project Options 中 Compiler 頁籤上的 Optimization 不勾選,重新 build 一遍就是了 要 build 喔,光 compile 不行的
------
歡迎參訪 "腦殘賤貓的備忘錄" http://maolaoda.blogspot.com/ |
waytounknow
一般會員 發表:4 回覆:7 積分:2 註冊:2007-08-11 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |