Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SoapySDRDevice_setupStream compatibility stuff breaks linking when compiler decides against actually inlineing #220

Closed
jazzkutya opened this issue Apr 11, 2019 · 3 comments

Comments

@jazzkutya
Copy link

jazzkutya commented Apr 11, 2019


vrm@zivatar:~/go/src/github.com/pothosware/go-soapy-sdr/pkg/device$ go build       
# github.com/pothosware/go-soapy-sdr/pkg/device
/tmp/go-build109665752/b001/_x003.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x004.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x005.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x006.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x007.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x008.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x009.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x010.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x011.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x012.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x013.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x014.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x015.o: In function `SoapySDRDevice_setupStream_':
/usr/local/include/SoapySDR/Device.h:310: multiple definition of `SoapySDRDevice_setupStream_'
/tmp/go-build109665752/b001/_x002.o:/usr/local/include/SoapySDR/Device.h:310: first defined here
/tmp/go-build109665752/b001/_x016.o: In function `SoapySDRDevice_setupStream_':

can be fixed by making it static inline in Device.h:

|      303 static inline int SoapySDRDevice_setupStream_(SoapySDRDevice *device,
|      304     SoapySDRStream **stream,
|      305     const int direction,
|      306     const char *format,
|      307     const size_t *channels,
|      308     const size_t numChans,
|      309     const SoapySDRKwargs *args)
|-     310 {
||     311     *stream = SoapySDRDevice_setupStream(device, direction, format, channels, numChans, args);
||     312     return (*stream == NULL)?-1:0;
||     313 }

@guruofquality
Copy link
Contributor

The amount of typos that I fixed related to this one stupid function...

Thanks, its fixed!

@jazzkutya
Copy link
Author

jazzkutya commented Apr 12, 2019

https://gustedt.wordpress.com/2010/11/29/myth-and-reality-about-inline-in-c99/
it seems this is actually not the proper fix, but the topic has confusion and compiler-dependent. I leave it to you to decide what to do :)

@guruofquality
Copy link
Contributor

It should have been static inline for a function. Otherwise you get a replication of the symbol in every file you include it in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants