4 回答

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超7個(gè)贊
MPLAB
C18提供的庫(kù)是使用大代碼模型編譯(-ml 命令行選項(xiàng))的。默認(rèn)情況下,MPLAB
IDE和編譯器將使用小代碼模型編譯應(yīng)用程序。例如,隨編譯器提供的printf函數(shù)期望收到“const far rom char
*”,但沒(méi)有為應(yīng)用程序選擇大代碼模型時(shí),應(yīng)用程序?qū)嶋H發(fā)送“const near rom char *”到printf
函數(shù)。正是far和near間的差別引起了“type qualifier mismatch in
assignment”警告。要消除這些警告,應(yīng)采取以下三種措施中的一種:
1) 使用小代碼模型重新編譯隨MPLAB C18 提供的庫(kù)(僅在所有應(yīng)用程序均使用小代碼模型時(shí)推薦);
2) 在IDE 中為特定應(yīng)用程序啟用大代碼模型(可能會(huì)增加代碼尺寸);
3) 將常量字符強(qiáng)制轉(zhuǎn)換為常量far rom 字符串指針,如:printf ((const far rom char *)”This is a test\n\r”);
其中2)更改方法如下:
當(dāng)通過(guò)包含stdio.h 使用標(biāo)準(zhǔn)庫(kù)時(shí),應(yīng)為項(xiàng)目選擇大代碼模型。轉(zhuǎn)到Project>Build Options>Project
對(duì)話框,并選擇MPLAB C18 選項(xiàng)卡,然后選擇Categories: Memory Model (類別:存儲(chǔ)模型)并選中Large code
model (> 64Kbytes) (大代碼模型(> 64 KB))。

TA貢獻(xiàn)1850條經(jīng)驗(yàn) 獲得超11個(gè)贊
主要軟件版本: 3.1
主要軟件修正版本: N/A
次要軟件: N/A
解答:回調(diào)函數(shù)是在某些特定的條件下由Testsdand引擎調(diào)用的序列。Testsdand有三種回調(diào)函數(shù)序列,取決于回調(diào)函數(shù)在哪里定義以及調(diào)用回調(diào)函數(shù)的實(shí)體。
Model回調(diào)函數(shù)Model回調(diào)函數(shù)是在過(guò)程模型(process model)文件或是在客戶序列(client sequence)文件中定義的,并且是在過(guò)程模型(process model)中的序列調(diào)用的。Model回調(diào)函數(shù)可以實(shí)現(xiàn)過(guò)程模型(process model)中的每個(gè)序列自定義的運(yùn)行。您可以在過(guò)程模型(process model)文件中創(chuàng)建Model回調(diào)函數(shù),標(biāo)記為Model回調(diào)函數(shù),并且在執(zhí)行進(jìn)入點(diǎn)(execution entry points.)調(diào)用。如果在序列文件中定義與過(guò)程模型(process model)文件同名的回調(diào)函數(shù),就可以按照自定義的序列文件中的序列執(zhí)行,更改在Edit>>Sequence File Callbacks。
Engine 回調(diào)函數(shù)Engine 回調(diào)函數(shù)的名稱是預(yù)先定義的,并且由引擎在特定的執(zhí)行進(jìn)入點(diǎn)調(diào)用。根據(jù)Engine 回調(diào)函數(shù)定義的位置不同,可分為三組,Engine 回調(diào)函數(shù)可以分別在StationCallbacks.seq, the process model file, 或者 the test sequence file中定義。
Front-End回調(diào)函數(shù)Front-End回調(diào)函數(shù)位于Front-EndCallbacks.seq file中。用戶可以在FrontEndCallbacks.seq中以序列的方式自定義要進(jìn)行的前端操作。FrontEndCallbacks.seq在目錄\Components\NI\Callbacks\FrontEnd中。Front-End回調(diào)函數(shù)也支持多操作界面共享前端操作,比如說(shuō)用戶登陸窗口。
相關(guān)鏈接:Developer Zone Tutorial: Adding Custom Callbacks to TestStandModel.seqDeveloper Zone Tutorial: Modifying How TestStand Executes Sequences (Changing the Default TestStand Process Model)Developer Zone Tutorial: When should I Implement Changes to the Process Model Instead of Using Callbacks?

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超8個(gè)贊
scanf("%d",&num);
printf("%d",num);
因?yàn)閟canf and printf是格式化輸出,所以分兩個(gè)部分,第一部分用分號(hào)擴(kuò)起,%加格式,%d代表整數(shù)十進(jìn)制,后面是相關(guān)數(shù)據(jù),但scanf 將取得數(shù)據(jù) 放到num地址 所以加取地址符號(hào)&
而printf使用是 直接跟想輸出的數(shù)的變量名字num
#include <stdio.h>
void main( void )
{
int i, result;
float fp;
char c, s[81];
wchar_t wc, ws[81];
printf( "\n\nEnter an int, a float, two chars and two strings\n");
result = scanf( "%d %f %c %C %s %S", &i, &fp, &c, &wc, s, ws );
printf( "\nThe number of fields input is %d\n", result );
printf( "The contents are: %d %f %c %C %s %S\n", i, fp, c, wc, s, ws);
wprintf( L"\n\nEnter an int, a float, two chars and two strings\n");
result = wscanf( L"%d %f %hc %lc %S %ls", &i, &fp, &c, &wc, s, ws );
wprintf( L"\nThe number of fields input is %d\n", result );
wprintf( L"The contents are: %d %f %C %c %hs %s\n", i, fp, c, wc, s, ws);
}
輸出
Enter an int, a float, two chars and two strings
71
98.6
h
z
Byte characters
The number of fields input is 6
The contents are: 71 98.599998 h z Byte characters
Enter an int, a float, two chars and two strings
36
92.3
y
n
Wide characters
The number of fields input is 6
The contents are: 456 92.300003 y n Wide characters
添加回答
舉報(bào)