我試着去編譯彙編語言和C代碼放在一起(不是C組裝)的頭文件,但不能把它做完。編譯彙編代碼,其中包括含C-定義
例如
文件COMMON.H
#ifndef __COMMON_H__
#define __COMMON_H__
struct tree{
tree* left;
tree* right;
void* elem;
};
void foo(int c);
#endif
文件common.S
#include "common.h"
.text
.globl foo
.ent foo
foo:
//foo implementation
.end foo
當我嘗試編譯此:
# gcc -c common.S
common.h: Assembler messages:
common.h:5: Error: unrecognized opcode `struct tree{'
common.h:7: Error: unrecognized opcode `tree* left'
common.h:8: Error: unrecognized opcode `tree* right'
common.h:10: Error: unrecognized opcode `void* elem'
common.h:12: Error: junk at end of line, first unrecognized character is `}'
common.h:14: Error: unrecognized opcode `void foo(int c)'
任何方式拿C定義到彙編usi中ng gcc?
在此先感謝。
林不知道這是一個選項。將。#include包含在.S中的想法不是我的。我在'arch /'部分讀取OS代碼,並在那裏包含.h文件。 – Tom
Ahh OK ..離開include並將其編譯爲不帶頭文件,然後 - 如果包含頭文件,則不需要編譯頭文件。 –
'#GCC -c common.S'相同的輸出:( – Tom