bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] GNU gperf 3.0.3


From: Bruno Haible
Subject: Re: [PATCH] GNU gperf 3.0.3
Date: Tue, 11 Mar 2008 00:27:55 +0100
User-agent: KMail/1.5.4

Hello,

Dimitri Papadopoulos-Orfanos wrote in
<http://lists.gnu.org/archive/html/bug-gnu-utils/2008-02/msg00042.html>:

> Would such a patch make sense to inline functions on more compilers than 
> currently supported?
> 
> It adds support for MSVC and C99 compilers.
>
> 
> --- output.cc.orig      2007-03-31 17:16:05.000000000 +0200
> +++ output.cc   2008-02-28 22:43:38.000000000 +0100
> @@ -746,12 +746,11 @@
>    if (option[CPLUSPLUS])
>      printf ("inline ");
>    else if (option[KRC] | option[C] | option[ANSIC])
> -    printf ("#ifdef __GNUC__\n"
> +    printf ("#if defined __GNUC__ || defined _MSC_VER\n"
>              "__inline\n"
> -            "#else\n"
> -            "#ifdef __cplusplus\n"
> +            "#elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 
> \\\n"
> +            " || defined __cplusplus\n"
>              "inline\n"
> -            "#endif\n"
>              "#endif\n");
>  
>    if (/* The function does not use the 'str' argument?  */

Regarding MSVC: The rules for 'inline' in C99 are a bit complicated, and
MSVC is not among the list of compilers that I know support it. [1]

Regarding C99 compilers: I agree that it would make sense to support 'inline'
for these compilers. The problem is that __STDC_VERSION__ is not dependable
in practice, and for a generated file it is out of question to use autoconf.

You can postprocess the file produced by gperf with 'sed' for example,
enabling the 'inline' when you know that the compiler supports it...

Bruno


[1] http://lists.gnu.org/archive/html/bug-gnulib/2006-11/msg00055.html





reply via email to

[Prev in Thread] Current Thread [Next in Thread]