Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Sun Studio cc includes unused static inline functions in object file

807578May 28 2009 — edited May 29 2009
While trying to compile some code originally compiled with GCC I run into a linking problem. My problem seems to be caused by that GCC does not include unused static inline functions in the object files while cc does. The following simple example can be used for illustrating this:
void foo();

static inline void bar()
{
  foo();
}

int main()
{

}
This program compiles and links without any problems using GCC and Sun Studio 12 CC (the C++ compiler) but fails to link using Sun Studio 12 cc:

khepri%> cc staticinline.c
Undefined first referenced
symbol in file
foo staticinline.o
ld: fatal: Symbol referencing errors. No output written to a.out

It is probably fine of cc to include foo() in the object file (although not necessary?). My questions are:

1. Are there any reasons for why cc includes unused static inline functions in the object file while CC does not?
2. Are there any ways or options to tell cc to not include unused static inline functions in the object file?

In the example above this is easy to fix by just removing or #ifdef away the code but the original code where I have this problem is not maintained by me and the static inline functions are in header files that get included in multiple C files and in some of these the functions are used.

Thanks,
Olav

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 26 2009
Added on May 28 2009
3 comments
333 views