[問題] 一段ti ccs編不過的code(己解決)

看板C_and_CPP作者 (我抓得到什麼呢?)時間9年前 (2015/05/28 14:02), 9年前編輯推噓0(008)
留言8則, 4人參與, 最新討論串1/1
開發平台(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

05/28 14:37, , 1F
typedef?
05/28 14:37, 1F
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

05/28 14:58, , 2F
少了分號?
05/28 14:58, 2F
找到一開始可能的問題了: 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

05/28 16:55, , 3F
WorkFreq並不是type
05/28 16:55, 3F

05/28 16:57, , 4F
只能typedef
05/28 16:57, 4F

05/28 16:57, , 5F
我也不確定
05/28 16:57, 5F

05/28 16:58, , 6F
05/28 16:58, 6F

05/28 17:11, , 7F
把WorkFreq改成struct WorkFreq試試?
05/28 17:11, 7F

05/28 17:11, , 8F
啊,推文已經有寫了
05/28 17:11, 8F
文章代碼(AID): #1LPg-Ed2 (C_and_CPP)