November 10, 2007
Hi,


On 2007/11/10, holmescn <holmesconan@gmail.com> wrote:
> HI,
> I have tried to build gdc with gcc 4.2.2 .
> I know it is not support yet.I just want to have a try.
> Then the problem is :
> when build the d-lang.glue.o , there are some errors in d-codegen.h
> there is a function named 'build'. I can't find the declaration of it, of course
> the same to the compiler.
> there are also functions named 'build1' 'build2' 'build3' . and the declaration of them are also missed.
> 
> Doesn't it strange? If the same code can work around gcc 4.1, what was happend? How can gcc 4.1 find the functions? where are they?
> anybody give me a hand?
> thank you!
> 


The gcc internals have changes between 4.1 and 4.2, this was in 4.1's tree.h:

> /* Construct various types of nodes.  */
> 
> extern tree build (enum tree_code, tree, ...);
> extern tree build_nt (enum tree_code, ...);
> 
> #if GCC_VERSION >= 3000 || __STDC_VERSION__ >= 199901L
> /* Use preprocessor trickery to map "build" to "buildN" where N is the
>    expected number of arguments.  This is used for both efficiency (no
>    varargs), and checking (verifying number of passed arguments).  */
> #define build(code, ...) \
>   _buildN1(build, _buildC1(__VA_ARGS__))(code, __VA_ARGS__)
> #define _buildN1(BASE, X)       _buildN2(BASE, X)
> #define _buildN2(BASE, X)       BASE##X
> #define _buildC1(...)           _buildC2(__VA_ARGS__,9,8,7,6,5,4,3,2,1,0,0)
> #define _buildC2(x,a1,a2,a3,a4,a5,a6,a7,a8,a9,c,...) c
> #endif


And here is what there is in 4.2's:

> /* Construct various types of nodes.  */
> 
> extern tree build_nt (enum tree_code, ...);


Looks like buildN are called “by hand” in objc and fortan front-ends.

There are also in ChangeLog-2003:

2003-05-17  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

        * builtins.c (validate_arglist): Eliminate libiberty VA_ macros,
        always use stdarg.
        [...]
        * tree.c (build, build_nt, build_function_type_list): Likewise.


Please let us know if you get something working, it would be so nice if gdc were ported to gcc-4.2. :-)


Have a nice day,

Arthur.