[cfe-dev] Compiling BRL-CAD with clang/clang++

Clifford Yapp cliffyapp at gmail.com
Sat Nov 20 15:51:35 PST 2010


Hi - not sure if I'm in the right mailing list for these questions,
but I'm trying to build BRL-CAD (http://brlcad.org) with clang/clang++
and running into a few things that have me guessing.  I'm not sure if
they are bugs or the fault of our own code (we do build successfully
with gcc), and any advice would be appreciated (I'm happy to file bug
reports but I don't want to waste time with things that aren't issues)

1)  When building with clang/clang++ and using the default ld linker,
we get failures to link on code like the following:

HIDDEN inline int
fnalnum(int c)
{
    return isalnum(c);
}

Removing the inline allows things to succeed, as does using llvm-ld
instead of ld - is this know/expected?


2)  We are getting the following error:

sh_prj.c:409:41: error: initializer element is not a compile-time
      constant
struct bu_structparse img_print_tab[] = {

on this bit of code:

struct bu_structparse img_print_tab[] = {
    {"%p",      bu_byteoffset(img_parse_tab[0]), "img_parse_tab", 0,
BU_STRUCTPARSE_FUNC_NULL },
    {"%f",      4, "i_plane",           IMG_AO(i_plane),
BU_STRUCTPARSE_FUNC_NULL},
    {"",        0, (char *)0,           0,
BU_STRUCTPARSE_FUNC_NULL}
};

the offending bu_byteoffset is (if I've walked through all the if
defined stuff right)

#define bu_byteoffset(_i)     ((size_t)((char *)&(_i)))

(full code for bu_byteoffset is defined in this file:
http://brlcad.svn.sourceforge.net/viewvc/brlcad/brlcad/trunk/include/bu.h?revision=41330)

This does work with gcc without complaining about compile-time
constantness - is there something new/specific to clang that forbids
this setup?

Any help appreciated.

CY



More information about the cfe-dev mailing list