The NMSettingProxyMethod enum only exists since NetworkManager 1.6.
So to make it compile with 1.4.x as well (which is the minimum supported version), use the corresponding numbers instead of the enum defines.
Details
- Reviewers
jgrulich - Commits
- R282:88f3093c5237: [proxysetting] Fix build with NM 1.4
Builds fine now with NM 1.4.x, before there were compiler errors:
In file included from /home/abuild/rpmbuild/BUILD/networkmanager-qt-VERSIONgit.20181211T113515~4332597/src/settings/proxysetting.cpp:21:0: /home/abuild/rpmbuild/BUILD/networkmanager-qt-VERSIONgit.20181211T113515~4332597/src/settings/proxysetting.h:43:16: error: 'NM_SETTING_PROXY_METHOD_NONE' was not declared in this scope None = NM_SETTING_PROXY_METHOD_NONE, ^ /home/abuild/rpmbuild/BUILD/networkmanager-qt-VERSIONgit.20181211T113515~4332597/src/settings/proxysetting.h:44:16: error: 'NM_SETTING_PROXY_METHOD_AUTO' was not declared in this scope Auto = NM_SETTING_PROXY_METHOD_AUTO ^
Still compiles with newer versions, tested with 1.6.0, 1.10.6, and 1.14.4.
Diff Detail
- Repository
- R282 NetworkManagerQt
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
I think the easiest solution here is just to set 0 and 1 to the enum values, instead of NM defines. I'm not sure if adding/removing enum is ABI compatible change, because the enum will disapper once you build it against NM 1.6.0+.
Sure, that would work as well.
But IMHO the version check would make it easier to remove this "hack" when the minimum NM version would be raised at some point in the future.
Whatever you prefer though.
I'm not sure if adding/removing enum is ABI compatible change, because the enum will disapper once you build it against NM 1.6.0+.
Hm, I see what you mean.
I don't think that really is a problem here though, as it is defined in libnm/nm-setting-proxy.h (in NM 1.6+) which is included by this file (via NetworkManager.h that's included by setting.h).
I.e. the enum will still be there when building against NM 1.6.0+ (otherwise the build would fail in the first place anyway, as it is used just a few lines below).
Sorry, I somehow read "API incompatible"...
TBH, I'm not sure about ABI either. But as this is outside of any class, it shouldn't be a problem? (as mentioned, it would be defined by another include file anyway when building against NM 1.6.0+)
Hm, maybe I should add extern "C" though?
This is inside G_BEGIN_DECLS/G_END_DECLS in nm-setting-proxy.h, which are defined as extern "C" { and } (according to the docs).
Fine with me.
Should I make that conditional depending on the NM version maybe, or just unconditionally use the numbers?