[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: argmatch: accept perfect matches in documented arglists
From: |
Akim Demaille |
Subject: |
Re: argmatch: accept perfect matches in documented arglists |
Date: |
Wed, 22 May 2019 07:18:34 +0200 |
Hi Paul,
> Le 21 mai 2019 à 18:18, Paul Eggert <address@hidden> a écrit :
>
> On 5/21/19 12:16 AM, Akim Demaille wrote:
>> I still use static inline, because with static only, GCC complains about
>> unused functions. If you have suggestions on the gnulib recommended way of
>> dealing with this, I'll adjust the code.
>
> I'm not quite following what you're trying to do there (that's an enormous
> macro -- can't you do whatever you're doing without macros? :-).
I wish I was not using macros, but argmatch works with any type, of any size.
So most of the functions must work with types of unknown sizes. In C++, that's
a straightforward use case for 'template', but we don't have this option here.
So I guess we have more or less three possibilities
1. use macros to generate structs and functions that depend on the type passed
as a parameter
2. play repeated #define TYPE foo + #include "generate-the-code.h" to do the
same thing but without all the slashes
3. try to have single implementation which plays with sizeof, offsetof, etc.
(I don't think m4 is considered an option here ;)
I tried 3, and it really messy. I never really considered 2, and after
discussing with Bruno, it appeared that 1 was acceptable. Instead of one giant
macros there could be several smaller one and a big one to call them all. It's
probably more maintainable, but makes no big difference.
> However, generally speaking static functions in .h files are a bad idea for C
> code, because a static function defined in a .h file cannot be called
> directly from an extern inline function defined in user code.
Actually, the macro should probably offer the user the choice to make the
symbols internal or external.
> To prevent GCC from complaining about the unused functions, you can use a
> pragma; this should suffice if the static functions are not intended to be
> called directly from user code. Or you can make the functions extern inline
> instead of static inline; Gnulib has a bunch of *INLINE* macros for this.
Yes, the user should be free to use any function specifier she wants,
including Gnulib's macros.
- Re: argmatch: accept perfect matches in documented arglists, (continued)
- Re: argmatch: accept perfect matches in documented arglists, Bruno Haible, 2019/05/19
- Re: argmatch: accept perfect matches in documented arglists, Akim Demaille, 2019/05/19
- Re: argmatch: accept perfect matches in documented arglists, Bruno Haible, 2019/05/19
- Re: argmatch: accept perfect matches in documented arglists, Akim Demaille, 2019/05/19
- Re: argmatch: accept perfect matches in documented arglists, Akim Demaille, 2019/05/19
- Re: argmatch: accept perfect matches in documented arglists, Bruno Haible, 2019/05/19
- Re: argmatch: accept perfect matches in documented arglists, Paul Eggert, 2019/05/19
- Re: argmatch: accept perfect matches in documented arglists, Akim Demaille, 2019/05/19
- Re: argmatch: accept perfect matches in documented arglists, Akim Demaille, 2019/05/21
- Re: argmatch: accept perfect matches in documented arglists, Paul Eggert, 2019/05/21
- Re: argmatch: accept perfect matches in documented arglists,
Akim Demaille <=
- Re: argmatch: accept perfect matches in documented arglists, Bruno Haible, 2019/05/22
- Re: argmatch: accept perfect matches in documented arglists, Akim Demaille, 2019/05/25