關於typedef的問題 |
答題得分者是:taishyang
|
ken0127
一般會員 發表:3 回覆:9 積分:7 註冊:2009-09-23 發送簡訊給我 |
這隻程式是參考網路上顯示卡的範例寫的
這邊只有擷取片段 用的也是顯卡提供的library 但遇到了一個問題 因為ADLDisplayModeInfo是一個指標 指到的是一個結構AdlDisplayModeInfo,但結構內還有一個結構ADLDetailedTiming 在run時一直不給過 一直出現[C Error] Unit1.cpp(263): E2108 Improper use of typedef 'ADLDisplayModeInfo' 並且停在 ADL_Display_ModeTimingOverride_Set ( iAdapterIndex, iDisplayIndex, ADLDisplayModeInfo, 1);那邊 是因為指標內還有指到結構的關係嗎?該如何解決? 因為顯卡的範例內並沒有說明這個函式的值範圍 故值皆是隨意指定的 [code cpp] 請在此區域輸入程式碼 typedef int ( *ADL_DISPLAY_MODETIMINGOVERRIDE_SET ) (int,int,ADLDisplayModeInfo*,int); #define ADL_DL_MODETIMING_STANDARD_DRIVER_DEFAULT 0x00000010 #define ADL_DL_TIMINGFLAG_DOUBLE_SCAN 0x0001 int Initialize() { int iAdapterIndex; int iDisplayIndex; ADLDisplayModeInfo AdlDisplayModeInfo; AdlDisplayModeInfo.iTimingStandard = ADL_DL_MODETIMING_STANDARD_DRIVER_DEFAULT; AdlDisplayModeInfo.iPossibleStandard = 1; AdlDisplayModeInfo.iRefreshRate =75; AdlDisplayModeInfo.iPelsWidth =1027; AdlDisplayModeInfo.iPelsHeight =768; AdlDisplayModeInfo.sDetailedTiming.iSize = 100; AdlDisplayModeInfo.sDetailedTiming.sTimingFlags = ADL_DL_TIMINGFLAG_DOUBLE_SCAN; AdlDisplayModeInfo.sDetailedTiming.sHTotal = 768; AdlDisplayModeInfo.sDetailedTiming.sHDisplay = 768; AdlDisplayModeInfo.sDetailedTiming.sHSyncStart = 0; AdlDisplayModeInfo.sDetailedTiming.sHSyncWidth = 768; AdlDisplayModeInfo.sDetailedTiming.sVTotal = 1024; AdlDisplayModeInfo.sDetailedTiming.sVDisplay = 1024; AdlDisplayModeInfo.sDetailedTiming.sVSyncStart = 0; AdlDisplayModeInfo.sDetailedTiming.sVSyncWidth = 1024; AdlDisplayModeInfo.sDetailedTiming.sPixelClock = 500; AdlDisplayModeInfo.sDetailedTiming.sHOverscanRight = 768; AdlDisplayModeInfo.sDetailedTiming.sHOverscanLeft = 0; AdlDisplayModeInfo.sDetailedTiming.sVOverscanBottom = 1; AdlDisplayModeInfo.sDetailedTiming.sVOverscanTop = 0; AdlDisplayModeInfo.sDetailedTiming.sOverscan8B = 1; AdlDisplayModeInfo.sDetailedTiming.sOverscanGR = 1; ADL_Display_ModeTimingOverride_Set ( iAdapterIndex, iDisplayIndex, ADLDisplayModeInfo, 1); 另外一個.h檔內有定義結構ADLDetailedTiming、ADLDisplayModeInfo的資料 typedef struct ADLDetailedTiming { int iSize; short sTimingFlags; short sHTotal; short sHDisplay; short sHSyncStart; short sHSyncWidth; short sVTotal; short sVDisplay; short sVSyncStart; short sVSyncWidth; short sPixelClock; short sHOverscanRight; short sHOverscanLeft; short sVOverscanBottom; short sVOverscanTop; short sOverscan8B; short sOverscanGR; } ADLDetailedTiming; typedef struct ADLDisplayModeInfo { int iTimingStandard; int iPossibleStandard; int iRefreshRate; int iPelsWidth; int iPelsHeight; ADLDetailedTiming sDetailedTiming; } ADLDisplayModeInfo; [/code] 懇請各位大大為我解答 謝謝 |
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
ken0127
一般會員 發表:3 回覆:9 積分:7 註冊:2009-09-23 發送簡訊給我 |
感謝taishyang大大的回覆
但還是一樣出現 [C Error] Unit1.cpp(263): E2108 Improper use of typedef 'ADLDisplayModeInfo' ===================引 用 taishyang 文 章=================== 試試 ADL_Display_ModeTimingOverride_Set?(?iAdapterIndex,?iDisplayIndex, &ADLDisplayModeInfo,?1); |
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
1.
typedef int ( *ADL_DISPLAY_MODETIMINGOVERRIDE_SET ) (int,int,ADLDisplayModeInfo*,int); 2. ADLDisplayModeInfo AdlDisplayModeInfo; 3. ADL_Display_ModeTimingOverride_Set ( iAdapterIndex, iDisplayIndex, ADLDisplayModeInfo, 1); 有沒有 * ,統一一下吧,有 *,有有 * 的傳入方式,沒有 * ,有沒有 * 的宣告方法 另外 typedef double (*Addition)(double value1, double value2);宣告,最好別偷懶 ===================引 用 ken0127 文 章=================== 這隻程式是參考網路上顯示卡的範例寫的 這邊只有擷取片段 用的也是顯卡提供的library 但遇到了一個問題 因為ADLDisplayModeInfo是一個指標 指到的是一個結構AdlDisplayModeInfo,但結構內還有一個結構ADLDetailedTiming 在run時一直不給過 一直出現[C Error] Unit1.cpp(263): E2108 Improper use of typedef 'ADLDisplayModeInfo' 並且停在ADL_Display_ModeTimingOverride_Set ( iAdapterIndex, iDisplayIndex, ADLDisplayModeInfo, 1);那邊 是因為指標內還有指到結構的關係嗎?該如何解決? 因為顯卡的範例內並沒有說明這個函式的值範圍 故值皆是隨意指定的 [code cpp] 請在此區域輸入程式碼 typedef int ( *ADL_DISPLAY_MODETIMINGOVERRIDE_SET ) (int,int,ADLDisplayModeInfo*,int); #define ADL_DL_MODETIMING_STANDARD_DRIVER_DEFAULT 0x00000010 #define ADL_DL_TIMINGFLAG_DOUBLE_SCAN 0x0001 int Initialize() { int iAdapterIndex; int iDisplayIndex; ADLDisplayModeInfo AdlDisplayModeInfo; AdlDisplayModeInfo.iTimingStandard = ADL_DL_MODETIMING_STANDARD_DRIVER_DEFAULT; AdlDisplayModeInfo.iPossibleStandard = 1; AdlDisplayModeInfo.iRefreshRate =75; AdlDisplayModeInfo.iPelsWidth =1027; AdlDisplayModeInfo.iPelsHeight =768; AdlDisplayModeInfo.sDetailedTiming.iSize = 100; AdlDisplayModeInfo.sDetailedTiming.sTimingFlags = ADL_DL_TIMINGFLAG_DOUBLE_SCAN; AdlDisplayModeInfo.sDetailedTiming.sHTotal = 768; AdlDisplayModeInfo.sDetailedTiming.sHDisplay = 768; AdlDisplayModeInfo.sDetailedTiming.sHSyncStart = 0; AdlDisplayModeInfo.sDetailedTiming.sHSyncWidth = 768; AdlDisplayModeInfo.sDetailedTiming.sVTotal = 1024; AdlDisplayModeInfo.sDetailedTiming.sVDisplay = 1024; AdlDisplayModeInfo.sDetailedTiming.sVSyncStart = 0; AdlDisplayModeInfo.sDetailedTiming.sVSyncWidth = 1024; AdlDisplayModeInfo.sDetailedTiming.sPixelClock = 500; AdlDisplayModeInfo.sDetailedTiming.sHOverscanRight = 768; AdlDisplayModeInfo.sDetailedTiming.sHOverscanLeft = 0; AdlDisplayModeInfo.sDetailedTiming.sVOverscanBottom = 1; AdlDisplayModeInfo.sDetailedTiming.sVOverscanTop = 0; AdlDisplayModeInfo.sDetailedTiming.sOverscan8B = 1; AdlDisplayModeInfo.sDetailedTiming.sOverscanGR = 1; ADL_Display_ModeTimingOverride_Set ( iAdapterIndex, iDisplayIndex, ADLDisplayModeInfo, 1); 另外一個.h檔內有定義結構ADLDetailedTiming、ADLDisplayModeInfo的資料 typedef struct ADLDetailedTiming { int iSize; short sTimingFlags; short sHTotal; short sHDisplay; short sHSyncStart; short sHSyncWidth; short sVTotal; short sVDisplay; short sVSyncStart; short sVSyncWidth; short sPixelClock; short sHOverscanRight; short sHOverscanLeft; short sVOverscanBottom; short sVOverscanTop; short sOverscan8B; short sOverscanGR; } ADLDetailedTiming; typedef struct ADLDisplayModeInfo { int iTimingStandard; int iPossibleStandard; int iRefreshRate; int iPelsWidth; int iPelsHeight; ADLDetailedTiming sDetailedTiming; } ADLDisplayModeInfo; [/code] 懇請各位大大為我解答 謝謝
編輯記錄
syntax 重新編輯於 2009-10-05 16:08:57, 註解 無‧
|
aftcast
站務副站長 發表:81 回覆:1485 積分:1763 註冊:2002-11-21 發送簡訊給我 |
路過,沒仔細看,但覺得有一點怪怪的
typedef struct ADLDisplayModeInfo { int iTimingStandard; int iPossibleStandard; int iRefreshRate; int iPelsWidth; int iPelsHeight; ADLDetailedTiming sDetailedTiming; } ADLDisplayModeInfo; 應該這樣寫… [code cpp] typedef struct tagADLDisplayModeInfo { int iTimingStandard; int iPossibleStandard; int iRefreshRate; int iPelsWidth; int iPelsHeight; ADLDetailedTiming sDetailedTiming; } ADLDisplayModeInfo; [/code]
------
蕭沖 --All ideas are worthless unless implemented-- C++ Builder Delphi Taiwan G+ 社群 http://bit.ly/cbtaiwan |
ken0127
一般會員 發表:3 回覆:9 積分:7 註冊:2009-09-23 發送簡訊給我 |
關於那段struct的寫法
是直接引用ATI官網放出來的.H檔 原本的寫法應該是可以的 ===================引 用 aftcast 文 章=================== 路過,沒仔細看,但覺得有一點怪怪的 ?typedef struct ADLDisplayModeInfo? ?{? ?? int? iTimingStandard;? ?? int? iPossibleStandard;? ?? int? iRefreshRate;? ?? int? iPelsWidth;? ?? int? iPelsHeight;? ?? ADLDetailedTiming? sDetailedTiming;? ?} ADLDisplayModeInfo; 應該這樣寫… [code cpp] ?typedef struct tagADLDisplayModeInfo? ?{? ?? int? iTimingStandard;? ?? int? iPossibleStandard;? ?? int? iRefreshRate;? ?? int? iPelsWidth;? ?? int? iPelsHeight;? ?? ADLDetailedTiming? sDetailedTiming;? ?} ADLDisplayModeInfo; [/code] |
aftcast
站務副站長 發表:81 回覆:1485 積分:1763 註冊:2002-11-21 發送簡訊給我 |
|
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
ken0127
一般會員 發表:3 回覆:9 積分:7 註冊:2009-09-23 發送簡訊給我 |
|
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |