导入/导出向导可以处理符号定义。使用 File->Import 并选择 C/C++ Project Settings。
导入向导所需的 XML 格式可以使用一个小的一次性脚本从活动符号的文本文件中创建。
我使用了以下 python 脚本:
#
# Tool to import a list of defined symbols into Eclipse IDE for code highlighting.
#
# Takes a _cdef.txt file (generated during library build) and converts to an XML file
# suitable for import into Eclipse
# Use stdin and stdout for input and output.
import sys
import string
header = [
'<?xml version="1.0" encoding="UTF-8"?>',
'<cdtprojectproperties>'
,
'<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros">',
'<language name="holder for library settings">',
'',
'</language>',
'<language name="GNU C++">',
'',
'</language>',
'<language name="GNU C">',
''
]
sys.stdout.write (string.join(header, '\n'))
text=sys.stdin.readlines()
tokens = string.split(string.strip(text[0]),',')
for curtok in tokens:
lines = ['<macro>',
'<name>' + string.strip(curtok) + '</name><value></value>',
'</macro>', '']
sys.stdout.write(string.join(lines, '\n'))
footer = [
'',
'</language>',
'<language name="Assembly">',
'',
'</language>',
'</section>',
'</cdtprojectproperties>',
'']
sys.stdout.write (string.join(footer, '\n'))
脚本的输入是一个文本文件,其中包含逗号分隔的活动符号,全部位于第一行。