Closed RLovelett closed 6 years ago
My bet is that you'll need to implement this module something like this: Wrapping C Code Within a Single Swift Package to get rid of this error. Edit: Package Manager C Language Target Support
Oh, good catch! Lemme see, I think there's another option that I've seen other C wrappers use. I'm going to upload a new release that probably fixes this.
Okay, here it is: https://github.com/felix91gr/Csdjournal/releases/tag/1.0.2 How's working for you?
Edit: fwiw, what I added is an #include
guard
Hmm, I'm testing it here and it doesn't work: it still says I have multiple definitions.
I'll try with what you said :)
The problem with that post is that it shouldn't work for System Packages (like systemd
). The supported way of importing C System Packages into Swift is by using a *.h
file in the root directory (basically what I did).
Maybe we can wrap this wrapper in a Swift package? Is that too crazy?
Okay, nevermind what I said. I thoroughly read IBM's implementation of their wrapper for CCurl, and after testing the usage of static inline
I found out that it fixes the double definition problem.
Tell me if it now works for you: https://github.com/felix91gr/Csdjournal/releases/tag/1.2.0
1.2.0 does it. Great job! Now once you get this included in Tracelog we'll be pretty close to a functional cross-platform logger. :+1:
You get this error if you have two source files, e.g.,
main.swift
andRequest.swift
, that bothimport CSDJournal
and make reference tocsd_journal_print
.I'm 99% sure this is due to the fact that
shim.h
is not just a header file but also includes the function implementation (which is why it fails at link time).