[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Symbols export control in libpoke
From: |
Mohammad-Reza Nabipoor |
Subject: |
Re: Symbols export control in libpoke |
Date: |
Sun, 25 Oct 2020 14:49:14 +0330 |
Hi, Jose.
On Sun, Oct 25, 2020 at 11:47:35AM +0100, Jose E. Marchesi wrote:
>
> Hi people!
>
> Right now we control which symbols get exported in libpoke by annotating
> function declarations with the "hidden" attribute, like in:
>
> pkl_compiler pkl_new (pvm vm, const char *rt_path)
> __attribute__ ((visibility ("hidden")));
>
> This works, but it is cumbersome to maintain and also error-prone: it is
> easy to forget to annotate new functions.
>
> Some time ago Tim Ruehsen suggested to use a different strategy: to pass
> a flag to GCC so it marks all symbols to have hidden visibility by
> default, and then to annotate the function declarations in
> libpoke/libpoke.h.
>
> I think the later approach is preferable.
> Opinions?
>
I agree.
I think we can have a macro like this:
```c
#define LIBPOKE_API __attribute__ ((visibility ("default")))
```
and mark all the public functions with this macro.
Also we can have a list of all public functions in a separate file and add
a testcase to check the `libpoke.so` against that file.
This way maintaining a stable API is much simpler and less error-prone.
Adding/removing of symbols is also explicit.
Regards,
Mohammad-Reza