[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: cross compiling problems



 | extern inline int foo(int a) { return a; }
 | main() { printf("hello %d\n", foo(7)); }
 | 
 | というようなものを cc hello.c でコンパイルした場合、
 | undefined foo となってしまうのでしょうか?

うーん、gcc.infoによると

   This combination of `inline' and `extern' has almost the effect of a
macro.  The way to use it is to put a function definition in a header
file with these keywords, and put another copy of the definition
(lacking `inline' and `extern') in a library file.  The definition in
the header file will cause most calls to the function to be inlined.
If any uses of the function remain, they will refer to the single copy
in the library.

   GNU C does not inline any functions when not optimizing.  It is not
clear whether it is better to inline or not, in this case, but we found
that a correct implementation when not optimizing was difficult.  So we
did the easy thing, and turned it off.

ということなので、そういう仕様かと...
---
UCHIYAMA Yasushi
uch@nop.or.jp