![](/img/trans.png)
[英]Why am I getting this error? "signal: illegal instruction (core dumped)"
[英]Why am I getting “Error: bad instruction” in an enum in C?
這很奇怪,對我沒有任何意義。 我在 .h 文件 u-boot 中添加了以下枚舉:
typedef enum LP5521_Patterns_Tag
{
LP5521_EB_ALL_GOOD,
LP5521_EB_CLEAR_ALL,
LP5521_EB_CONNECTED_TO_INTERNET,
LP5521_EB_ENERGY_BRIDGE_FOUND,
LP5521_EB_NO_SIGNAL,
LP5521_EB_PLUGGED_IN,
LP5521_EB_POOR_CONNECTION,
LP5521_EB_SERACH_WIFI,
LP5521_SET_COLOR,
LP5521_SET_CURRENT,
LP5521_SET_COLOR_CURRENT,
LP5521_PATTERNS_TOTAL
}LP5521_Patterns_T;
但是當我嘗試編譯它時,我收到以下錯誤:
include/configs/lp5521.h: Assembler messages:
include/configs/lp5521.h:7: Error: bad instruction `typedef enum LP5521_Patterns_Tag'
include/configs/lp5521.h:8: Error: junk at end of line, first unrecognized character is `{'
include/configs/lp5521.h:9: Error: bad instruction `lp5521_eb_all_good,'
include/configs/lp5521.h:10: Error: bad instruction `lp5521_eb_clear_all,'
include/configs/lp5521.h:11: Error: bad instruction `lp5521_eb_connected_to_internet,'
include/configs/lp5521.h:12: Error: bad instruction `lp5521_eb_energy_bridge_found,'
include/configs/lp5521.h:13: Error: bad instruction `lp5521_eb_no_signal,'
include/configs/lp5521.h:14: Error: bad instruction `lp5521_eb_plugged_in,'
include/configs/lp5521.h:15: Error: bad instruction `lp5521_eb_poor_connection,'
include/configs/lp5521.h:16: Error: bad instruction `lp5521_eb_serach_wifi,'
include/configs/lp5521.h:17: Error: bad instruction `lp5521_set_color,'
include/configs/lp5521.h:18: Error: bad instruction `lp5521_set_current,'
include/configs/lp5521.h:19: Error: bad instruction `lp5521_set_color_current,'
include/configs/lp5521.h:20: Error: bad instruction `lp5521_patterns_total'
include/configs/lp5521.h:21: Error: junk at end of line, first unrecognized character is `}'
我注意到在頂部它說匯編消息,但我也不明白。 我已經添加了一個 .c 文件,其中包含一堆 typedef 枚舉,但我沒有收到任何錯誤。
誰能幫我弄清楚這里發生了什么?
我不知道這是否有幫助,但我正在向 u-boot 和 imx6 交叉編譯添加一些代碼。
謝謝!!
U-boot 包含大量的 CPP 預處理匯編文件(即.S
而不是.s
); 板配置頭可能是包含在幾乎所有內容(C 文件、匯編文件、鏈接器腳本)中的一件事,因為它通常不僅定義選項,還定義板特定的物理地址等。
Ergo 把除 #defined 符號以外的任何東西都放在里面幾乎是在自找麻煩。
像這樣包裝這個枚舉:
#if !defined(__ASSEMBLER__)
typedef enum LP5521_Patterns_Tag
{
LP5521_EB_ALL_GOOD,
LP5521_EB_CLEAR_ALL,
LP5521_EB_CONNECTED_TO_INTERNET,
LP5521_EB_ENERGY_BRIDGE_FOUND,
LP5521_EB_NO_SIGNAL,
LP5521_EB_PLUGGED_IN,
LP5521_EB_POOR_CONNECTION,
LP5521_EB_SERACH_WIFI,
LP5521_SET_COLOR,
LP5521_SET_CURRENT,
LP5521_SET_COLOR_CURRENT,
LP5521_PATTERNS_TOTAL
}LP5521_Patterns_T;
#endif
為 Assembler 定義 _ ASSEMBLER _ 符號,它應該可以工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.