17 June 2005

Solaris Development Tip

Beware /usr/ucb.

By default this is in your path, and if you want to use the SUN Studio compilers to compile anything and everything, you need to either put /usr/ucb after /opt/SUNWpro/bin in your path, or take it out completely (highly recommended).

The reason for this? As far as I can tell /usr/ucb/cc implies -Xs, since /usr/ucb/cc is designed to act as an interface to the BSD Compatibility Package C compiler. So, if you go along your merry way and try to compile source code that uses C99 extensions, such as the following:

#define a(...) foo

You may encounter bizarre errors such as:
"test.c", line 1: bad formal: .
"test.c", line 1: bad formal: .
"test.c", line 1: bad formal: .

What clued me into what was wrong was the following warning when I tried to enable c99 extensions:
/usr/ucb/cc -xc99=all -o test test.c
cc: Option -Xs requires -xc99=none

Obviously, I'm not passing -Xs myself, so /usr/ucb/cc must be implying it automatically. I encountered this while trying to compile the latest version of metacity (the default GNOME window manager). While I realise many Solaris old-timers may already know about this, I thought I would pass it along as I'm fairly new to Solaris development myself.

I've been told and have read comments by a few different friendly SUN engineers that there is no good reason to have /usr/ucb in my path. I plan to follow their advice.


Technorati Tags:

1 comment:

kreaper said...

/usr/ucb and its associated dir (ucbinclude and ucblib) are part of what SUN calls the Source Compatibility Package.

T'is from the Software Developer AnswerBook:

"The SunOS/BSD Source Compatibility Package is an optional package in the SunOS 5.x operating system that makes available many SunOS 4.1 and BSD interfaces otherwise not included, or which may differ in functionality between the SunOS 4.1 and SunOS 5.x releases. This package should be used as a transition aid, and your future development should not depend on its continued existence."