fvwmorg / fvwm3

FVWM version 3 -- the successor to fvwm2
Other
511 stars 78 forks source link

Implicit function _IceTransNoListen in fsm.c #1031

Closed kro-cat closed 3 months ago

kro-cat commented 4 months ago

With libICE installed, autoconf successfully detects _IceTransNoListen, but fsm.c doesn't correctly declare this function (nor does its included header files). This causes the build to fail due to the implicit declaration of function _IceTransNoListen; this is located in fsm.c: https://github.com/fvwmorg/fvwm3/blob/f0366381a1bff42235d5e28019aed75d8c2e93e5/libs/fsm.c#L1048

Since _IceTransNoListen is neither defined nor declared in libICE headers (it is in fact declared in Xtrans.h, not packaged with libICE), it would be appropriate to use an extern declaration for the function:

#ifdef HAVE__ICETRANSNOLISTEN
extern void _IceTransNoListen(char *protocol);
#endif
ThomasAdam commented 4 months ago

Maybe. I'd rather fix the headers though so we're including the correct things, rather than chucking extern at it, as you're suggesting.

Can you open a PR when you've done that, please?

kro-cat commented 3 months ago

Not a problem, I'll use the header and make sure that's set up correctly. If that's somehow not possible, I'll make a note of it here. Should have a PR up sometime soon.

kro-cat commented 3 months ago

On my system, and perhaps other systems, xtrans.h is in a separate package (ie xtrans) from libICE (ie libice), and is not one of it's dependencies.

In the case that libice is installed and xtrans isn't (or perhaps it may be useful to consider the case in which xtrans.h isn't packaged at all), I could either switch how the function is declared:

/* example 1 */
#if defined(HAVE_XTRANS_H) && defined(HAVE__ICETRANSNOLISTEN)
#include <X11/Xtrans/Xtrans.h>
#elif defined(HAVE__ICETRANSNOLISTEN)
#warn "Maybe warn something? Probably don't need to."
extern void _IceTransNoListen(char *protocol);
#endif

or whether the function is used:

/* example 2 */
/* up top */
#if defined(HAVE_XTRANS_H) && defined(HAVE__ICETRANSNOLISTEN)
#include <X11/Xtrans/Xtrans.h>
#endif

/* ... */

/* in fsm_init() */
#if defined(HAVE_XTRANS_H) && defined(HAVE__ICETRANSNOLISTEN)
        _IceTransNoListen("tcp");
#endif

If you prefer one way or another, let me know. For now, I'll use the first example since that appears to me to be the traditional approach.

ThomasAdam commented 3 months ago

Hi @kro-cat

I think the first option you've suggested makes the most sense.

Thanks!