emcrisostomo / fswatch

A cross-platform file change monitor with multiple backends: Apple OS X File System Events, *BSD kqueue, Solaris/Illumos File Events Notification, Linux inotify, Microsoft Windows and a stat()-based backend.
https://emcrisostomo.github.io/fswatch/
GNU General Public License v3.0
4.96k stars 327 forks source link

Configuration header leaked into public interface in v. 1.17.0 #291

Open ziotom78 opened 2 years ago

ziotom78 commented 2 years ago

Hi, I am trying to compile the following program using libfswatch 1.17:

#include <libfswatch/c/libfswatch.h>
#include <stdio.h>

void my_callback(fsw_cevent const *const events, const unsigned int event_num, void * data) {
    puts("Called!");
}

int main() {
    // Initialize the library
    fsw_init_library();

    // Use the default monitor.
    const FSW_HANDLE handle = fsw_init_session(system_default_monitor_type);
    fsw_add_path(handle, "my/path");
    fsw_set_callback(handle, my_callback, NULL);
    fsw_start_monitor(handle);
}

I downloaded and installed the tarball for version 1.17 using the instructions found in the INSTALL file:

$ ./configure --prefix=$HOME/fswatch1.17 && make && make install

but the compiler complains about a missing libfswatch/libfswatch_config.h:

$ gcc -o test $(pkg-config --with-path $HOME/fswatch1.17/lib/pkgconfig --cflags --libs libfswatch) test.c
/home/tomasi/fswatch1.17/include/libfswatch/c/libfswatch_types.h:31:10: fatal error: libfswatch/libfswatch_config.h: No such file or directory
   31 | #include "libfswatch/libfswatch_config.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
$

However, the very same program compiles correctly if I install the tarball for version 1.16 and use it instead of 1.17:

$ gcc -o test $(pkg-config --with-path $HOME/fswatch1.16/lib/pkgconfig --cflags --libs libfswatch) test.c
$

It seems that the file libfswatch_types.h needs to include libfswatch_config.h because of this commit, but the file does not get installed by default.

emcrisostomo commented 2 years ago

Thanks @ziotom78, I'll have a look at it

randrej commented 2 years ago

My project also fails to build because of this bug. It's present in the AUR build.

emcrisostomo commented 2 years ago

Actually, that file (a configuration header) should not be visible in an public interface header. It's correct that the configuration header does not get installed. I'll patch this, thanks for the report.

emcrisostomo commented 2 years ago

I've updated that header. I've tried to compile your program locally @ziotom78 and it's working. Would you folks be willing. to test it before I merge it into master? Here's the candidate release tarball. fswatch-1.17.1.tar.gz

ziotom78 commented 2 years ago

Hi @emcrisostomo , thanks, I can confirm that the problem is solved in version 1.17.1.

Thanks a lot!

emcrisostomo commented 2 years ago

Thanks for trying it out so quickly. I'm closing this and will merge to master.

meator commented 1 year ago

Hi. I think I might be getting the same error for C++ binding of libfswatch of version 1.17.1.

In file included from main.cpp:1:
<PREFIX>/lib/include/libfswatch/c++/monitor.hpp:33:12: fatal error: libfswatch/libfswatch_config.h: No such file or directory
   33 | #  include "libfswatch/libfswatch_config.h"
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
emcrisostomo commented 1 year ago

Yes, it's correct, thanks for pointing that out @meator