[bind10-dev] Part 2: compiling with SunStudio12.1

JINMEI Tatuya / 神明達哉 jinmei at isc.org
Wed Jun 23 02:08:53 UTC 2010


At Tue, 22 Jun 2010 14:28:10 -0500 (CDT),
"Jeremy C. Reed" <jreed at isc.org> wrote:

> My boost is built/installed when SunStudio was not installed - just GCC 
> then.

That shouldn't matter because we basically use boost in the
header-only mode (unless we enable boost.python, but we'll soon drop
that, too).

I've resolved most of the issues within our own source code, and
actually saw b10-auth be built and work correctly.  One thing I was
not fully satisfied is that this compiler doesn't seem to handle
top-level const in function declarations correctly, causing link
errors.

For example, if we declare

int foo(int x);

in foo.h and define it in foo.cc as follows:

int foo(const int x) {
  ...
}

The Sun Studio compiler considers these two have different
signatures.  So foo.o will define the latter signature while another
object, say bar.o, generated from bar.cc that includes foo.h, requests
the former signature.  As a result, the build fails at the linker
stage.

As far as I understand it the C++ standard requires to consider these
two identical in terms of type matching, so it should be a compiler
bug.

I've googled for a couple of hours to see whether I can avoid that via
some compiler options, but there didn't seem to be a reasonable
solution (sometimes -g magically solved some of this types of problem,
but it didn't always work, and in any case optimization options seem
to suppress the effect).

I hate redundancy just as much as I like consistency, but in this case
the only pragmatic workaround is to add the redundant const to
declarations.  I've also seen this mismatch sometimes confuse doxygen,
so the redundancy may also help in documentation.

But if someone knows a better solution, I'd very much appreciate it.

---
JINMEI, Tatuya



More information about the bind10-dev mailing list