Richard W_M_ Jones commented:
There's actually a trick using `typeof` which avoids redefining each variable type (and it's more type safe).  However I'm not sure if it requires a GCC extension or not.  See example:
```
#include <stdio.h>                                                              
#include <stdlib.h>                                                             
#include <assert.h>                                                             
#include <tss2/tss2_esys.h>                                                     
#include <dlfcn.h>                                                              
                                                                                
typeof(Esys_Initialize) (*my_Esys_Initialize);                                  
typeof(Esys_Finalize) (*my_Esys_Finalize);                                      
                                                                                
int                                                                             
main ()                                                                         
{                                                                               
  void *dl = dlopen ("libtss2-esys.so.0", RTLD_NOW);                            
  assert (dl);                                                                  
                                                                                
  my_Esys_Initialize = dlsym (dl, "Esys_Initialize");                           
  assert (my_Esys_Initialize);                                                  
  my_Esys_Finalize = dlsym (dl, "Esys_Finalize");                               
  assert (my_Esys_Finalize);                                                    
                                                                                
  ESYS_CONTEXT *ctx;                                                            
  if (my_Esys_Initialize (&ctx, NULL, NULL)) {                                  
    fprintf (stderr, "Esys_Initialize failed\n");                               
    exit (1);                                                                   
  }                                                                             
                                                                                
  fprintf (stderr, "ctx = %p\n", ctx);                                          
                                                                                
  my_Esys_Finalize (&ctx);                                                      
  exit (0);                                                                     
}                                                                               
```
-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1544#note_853664582
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20220224/6f113269/attachment.html>