Reuben Thomas wrote:
> For a library. For example, from the libpaper commit referenced below,
> using #ifdefs:
> 
> /* Set the prefix directory for relocation. */
> void papersetprefixdir(const char *new_prefix)
> {
> #ifdef ENABLE_RELOCATABLE
>     set_relocation_prefix (INSTALLPREFIX, new_prefix);
> #else
>     (void)new_prefix;
> #endif
> }
> ...
> I'm asking because no package I know of is using set_relocation_prefix
> > explicitly [1]
> 
> I've been using it in Enchant since 2017[1] and in libpaper since 2021[2]
> 
> [1] https://github.com/AbiWord/enchant/commit/a8e771a

OK, I see. What you are doing is perfectly like it should be done:
  - papersetprefixdir is a function part of the public API of your library.
    It needs to be defined unconditionally.
  - set_relocation_prefix is defined in relocatable.c (module relocatable-lib
    or relocatable-lib-lgpl). This file is only compiled when $RELOCATABLE
    is 'yes' or (equivalently) 'defined ENABLE_RELOCATABLE'. When $RELOCATABLE
    is 'no', you get a link error when linking the library.

Can you please try the attached patch?

If it does not help, I would suggest that you move out the papersetprefixdir
function from a .vala compilation unit to a .c compilation unit, so that the
requirements of the Vala language and processor become irrelevant.

Bruno
diff --git a/lib/relocatable.h b/lib/relocatable.h
index 162f9d82a4..0c10ebe2a1 100644
--- a/lib/relocatable.h
+++ b/lib/relocatable.h
@@ -109,6 +109,8 @@ extern char * compute_curr_prefix (const char *orig_installprefix,
 #else
 
 /* By default, we use the hardwired pathnames.  */
+#define set_relocation_prefix(orig_prefix, curr_prefix) \
+  ((void) (orig_prefix), (void) (curr_prefix))
 #define relocate(pathname) (pathname)
 #define relocate2(pathname,allocatedp) (*(allocatedp) = NULL, (pathname))
 

Reply via email to