Define "feature macros" for symlink, make it compilable on cygwin#39
Define "feature macros" for symlink, make it compilable on cygwin#39Neui wants to merge 3 commits into
Conversation
f52e0ea to
204c0a8
Compare
|
Sorry for replying so late. Is this how those macros are supposed to be used (set by the user)? Regardless, it may be wise to check for symlink support during configure time so rdfind can compile also without it. That would require some kind of mechanism to inhibit the symlink tests. For a code change like this, some kind of CI for testing this is needed. Preferably cygwin. |
I already forgot about this.
According to the linked man page 7 feature_test_macros, these macros should just simply defined before including the appropriate header, like either on the command line or a simple On cygwin I get the 3p version of the man page which doesn't say anything about it, but also claims that the cygwin implementation can differ. With my initial comment above, it seems that defining
I believe autotools has such functionality available, but we still need to define those macros above so in case it is available it can be used.
I agree, but I haven't looked on how you would do that yet. AFAIK appveyor can run windows MSVC, but not sure if we can also use cygwin on there. |
|
Thanks for providing information on how to use the macros! I removed appveyor and moved what it ran into github actions instead. Do you think something https://github.com/egor-tensin/setup-cygwin could be used? |
|
This is a continuation of #56 as well, but fits better in this thread. I looked a bit more into the specific definitions that are needed to enable symlink. Symlink is defined in For our purposes the most important one is You can see here that this means we should set Sidenote, my earlier solution of just enabling all extensions is equivalent to defining I tested with |
Define _XOPEN_SOURCE and _POSIX_C_SOURCE appropriately in order to be
able to use functions such as symlink() on cygwin.
Before that it would error while running make about not being able to
find a function called "symlink". After looking into the header files,
I've found it requires at least one of those macros in order to be
defined.
The error was:
g++ -std=c++11 -DHAVE_CONFIG_H -I. -g -O2 -MT Fileinfo.o -MD -MP -MF .deps/Fileinfo.Tpo -c -o Fileinfo.o Fileinfo.cc
Fileinfo.cc: In lambda function:
Fileinfo.cc:280:14: error: ‘symlink’ was not declared in this scope
return symlink(target.c_str(), filename.c_str());
^~~~~~~
Fileinfo.cc:280:14: note: suggested alternative: ‘unlink’
return symlink(target.c_str(), filename.c_str());
^~~~~~~
unlink
Additionally, man 2 symlink (on Ubuntu 18.04) says, it'll be defined
for:
_XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L
|| /* Glibc versions <= 2.19: */ _BSD_SOURCE
However, defining _BSD_SOURCE would cause cygwin sys/feature.h to define
_DEFAULT_SOURCE, which in turns always redefines _POSIX_C_SOURCE,
causing an redefinition warning when the config.h file is processed
again. Thus _BSD_SOURCE isn't defined, for now.
This is also my first time modifying autoconfig files. I hope I did
everything alright.
It's to prevent redefinition warnings on systems other than cygwin such as Ubuntu.
It was determined that just defining _POSIX_C_SOURCE is enough to let symlink() be defined.
204c0a8 to
905a40d
Compare
No idea, I've never used GitHub Actions, but the repository looks like it could work. Because of BartLH I've now added a commit to just keep the |
|
I added a cygwin job in #136 . It did not require any changes. Help wanted to test if the cygwin executable works, and if it would be possible to execute the tests. Since no changes were needed to make it compile, I think this PR should be closed. Thanks for the work! |
Define
_XOPEN_SOURCEand_POSIX_C_SOURCEappropriately in order to be able to use functions such assymlink()on cygwin.Before that it would error while running make about not being able to find a function called
symlink. After looking into the header files, I've found it requires at least one of those macros in order to be defined.The error was:
Additionally,
man 2 symlink(on Ubuntu 18.04) says, it'll be defined for:However, defining
_BSD_SOURCEwould cause cygwinsys/feature.hto define_DEFAULT_SOURCE, which in turns always redefines_POSIX_C_SOURCE, causing an redefinition warning when theconfig.hfile is processed again. Thus_BSD_SOURCEisn't defined, for now.This is also my first time modifying autoconfig files. I hope I did everything alright. Note that it just builds and is functional (can find duplicates), but I haven't tried anything advanced yet (like dryrun, actually soft or hard symlinking).