看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) TI CCS + TI ARM compiler for stellaris or CCS + gcc arm (on Windows x86) 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) NONE 問題(Question): 編譯不過 餵入的資料(Input): NONE 預期的正確結果(Expected Output): 在msvc++2012(x86) /Wall編譯成功沒任何警告 錯誤結果(Wrong Output): 編不過 程式碼(Code):(請善用置底文網頁, 記得排版) struct WorkFreq{ int freq; int freq_real; int time[3]; int intensity; }; // extracted freq component for DOA analysis #pragma DATA_ALIGN(dma_ch_table, 1024) struct { int* src_endp; int* dst_endp; int ctrl; int not_used; } dma_ch_table[28]; // 14=adc0_ss0, 24=adc1_ss0 WorkFreq* work_freq = (WorkFreq*)&dma_ch_table; // size is 14, reuse empty dma structure 補充說明(Supplement): 要給mcu用的,想省一些記憶體,vc編起來也正常,dma[0~13]都不會用到 自學的C/C++,會不會是我碰到了未定義的行為? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.7.214 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1432792974.A.9C2.html ※ 編輯: kdjf (140.112.7.214), 05/28/2015 14:34:38
GoIt: typedef? 05/28 14:37
typedef struct { xxxx; } WorkFreq; WorkFreq* workfreq; 編過 可是還是不懂 struct WorkFreq { int freq; int freq_real; int time[3]; int intensity; } ; // extracted freq component for DOA analysis struct WorkFreq * work_freq= (WorkFreq*)&dma_ch_table; 這樣不過的原因是什麼 ※ 編輯: kdjf (140.112.7.214), 05/28/2015 14:47:29
Feis: 少了分號? 05/28 14:58
找到一開始可能的問題了: msvc"++"把我的code用c++標準編 gcc/ti c用c編,所以namespace不同 identifier "WorkFreq" is undefined 第二部份還是不懂 cast的地方也是要放type,所以正確的是,c++ vs c... struct WrokFreq* work_freq=(struct WrokFreq*)&dma_ch_table; ※ 編輯: kdjf (140.112.7.214), 05/28/2015 15:29:53
TobyH4cker: WorkFreq並不是type 05/28 16:55
TobyH4cker: 只能typedef 05/28 16:57
TobyH4cker: 我也不確定 05/28 16:57
TobyH4cker: 對 05/28 16:58
james732: 把WorkFreq改成struct WorkFreq試試? 05/28 17:11
james732: 啊,推文已經有寫了 05/28 17:11