A: 该问题是由gcc(ver2.7.2-2.95.2)试图改变它得到静态构造函数的方法引起的。它不再对每个构造静
态对象的模块消除函数,该方法是vxworks在编译链接过程中采用的方法。
你可以按如下修改gcc 2.95.2源代码后,恢复原先的操作。
in [source code dir]/gcc/config/arm/vxarm.h, at the very end, add:-
/* More DK patches: we undef these two in order to force the */
/* compiler to output our static constructors and destructors */
/* in the fashion to which it is accustomed.... */
typedef struct ex PackedStruct;
注意:如果可能,避免使用-fpack-struct编译器开关。我门最近移除了这个选项,使得我们的C++程序提高了
30%-100%的性能。这是因为每次存取结构或类里多字节值时,都是一个一个字节操作的。可以使用
__attribute__ ((packed)) 方法代替。
(From: Mark Fanara, mfanara@home.cNOSPAMMom, and Francisco Pataro, fpataro@dnaent.com)
2.1.8 我怎样在一个C程序文件里调用一个C++函数?
A: 如果你想在一个C程序文件里调用一个C++函数,C++函数必须用extern "C"声明;否则编译器将破坏函数名
,把参数类型说明加在函数名末尾,并返回该函数。
(From: Dave Korn)
addql #1,a0@(8)
如果采用-fvolatile 开关你会得到:
movel a0@(8),d0
addql #1,d0
movel d0,a0@(8)
movel a0@(8),d0
You can imagine what a C++ application using the "this" pointer everywhere gets compiled into!
(From: Chris Varlese, cv@no.mail.net)
1、把$(LIBS)替换成$(LD_PARTIAL) -o vxWorks.tmp $(MACH_DEP) usrConfig.o version.o
$(LIBS) (在target/h/rules.bsp文件中)。 Now LD_PARTIAL is ccxxx, so you need to specify -Wl,
--group-start to get cc to pass the argument to ld.
2、Try adding a -Usymbol for each symbol that has to be pulled in early.
3、如果办法2 make ld行太笨拙,生成一个.s文件,包含每个没定义的符号和加到链接里的。
4、如果你工作UNIX下,它应该可能得到ld生成没有定义的所要求的列表。你需要加一个循环,就象下面一
样:
/*这是原文,我翻译不好。
1、$(LIBS) is substituted into: $(LD_PARTIAL) -o vxWorks.tmp $(MACH_DEP) usrConfig.o version.o
$(LIBS) (in target/h/rules.bsp for a non-project build). Now LD_PARTIAL is ccxxx, so you need
to specify -Wl,--group-start to get cc to pass the argument to ld.
2、Try adding a -Usymbol for each symbol that has to be pulled in early.
3、If (2) make the ld line too unwieldy, generate a .s file that contains: .extern symbol for
each undefined symbol and include that into the link before the libraries
4、If your building on unix, it ought to be possible get ld to generate the required list of
undefines! You need to add a loop! Something like this might work:
*/
[ ! -f undefs.s ] && echo "#" >undefs.s
while
$(CC) -c $(CFLAGS) undefs.s
$(LD_PARTIAL) -o vxWorks.tmp $(MACH_DEP) usrConfig.o version.o \
undefs.o $(LIBS)
$(NM) vxWorks.tmp | grep ' __' | $(MUNCH) > ctdt.c
$(MAKE) CC_COMPILER="-fdollars-in-identifiers" ctdt.o
do
$(LD) $(LDFLAGS) -e $(SYS_ENTRY) $(LD_LOW_FLAGS) -o vxWorks \
dataSegPad.o vxWorks.tmp ctdt.o tad_hook_list.o 2>&1 | tee ld.errs |
while read file undef ref to symbol
do
[ "$undef" = "undefined" ] || continue
[ "$ref" = "reference" ] || continue
[ "$to" = "to" ] || continue
oifs="$IFS"
IFS="'/`"
symbol="`echo $symbol`"
IFS="$oifs"
echo "\t.extern\t$symbol"
done | sort -u - undefs.s >undefs.new
cmp -s undefs.s undefs.new && break
mv undefs.new undefs.s
done
cat ld.errs
当然它需要另一系列的ESC和; \在每一行,以使得可以在make下运行。
(我也重新构造了原始的rules.bsp内容,我的可能与vxWorks原来的有些不同。)
(From: David Laight, dsl@tadpole.co.uk)
2.1.11 警告"trigraphs occured"是什么意思?
A: 对Tornado或Vxoworks没什么要做的。
你可能在你代码(也可能在注释里)中有三字符序列--参看K&R (Kernighan & Ritchie; A12.1 - 这是
ANSI 新引进的。-- 但是GNU手册里提示"You don't want to know about this brain-damage..."
使用-ansi或-trigraphs开关,或更好的办法消除任何包含三字符序列'??X'的注释。 (参看K&R书中对X
的定义)。
(From: Michael.Ben-Ari@ecitele.com)