Reputation: 135
I have quite low experience with Objective C as I started learning iOS development using Swift and I need to use a older ObjC library.
My netsdk.h library (file has over 50k lines)
#ifndef DHNETSDK_H
#define DHNETSDK_H
#if (defined(WIN32) || defined(_WIN32) || defined(_WIN64))
...
#else //non-windows
#define CLIENT_NET_API extern "C"
#define CALL_METHOD
#define CALLBACK
...
Basically after reading some problems related to this one I think there is problem with extern "C"
on the next line
...
#define CLIENT_NET_API extern "C"
...
Due to this I am getting errors on many lines that use CLIENT_NET_API like
expected identifier or '('
Expanded from macro 'CLIENT_NET_API'
My first try was to wrap #define CLIENT_NET_API extern "C"
into
#ifdef __cplusplus
extern "C" {
#endif
#define CLIENT_NET_API
#ifdef __cplusplus
}
#endif
but then I am getting error "C does not support default arguments"
on all lines using CLIENT_NET_API
for example these
CLIENT_NET_API BOOL CALL_METHOD CLIENT_StartBackUpCase(LLONG lLoginID, const NET_IN_START_CASE_BACK_UP* pstInParam, NET_OUT_START_CASE_BACK_UP *pstOutParam, int nWaitTime = NET_INTERFACE_DEFAULT_TIMEOUT);
CLIENT_NET_API BOOL CALL_METHOD CLIENT_StopBackUpCase(LLONG lLoginID, const NET_IN_STOP_CASE_BACK_UP* pstInParam, NET_OUT_STOP_CASE_BACK_UP *pstOutParam, int nWaitTime = NET_INTERFACE_DEFAULT_TIMEOUT);
I think it should be wrapped in some other way but I couldn't find a example with #define
and extern
keywords on the same line
Upvotes: 1
Views: 450
Reputation: 27211
In this case:
Says, let CLIENT_NET_API
be extern "C"
So, in your case you just define as empty existed preprocessor variable
#ifdef __cplusplus
extern "C" {
#endif
#define CLIENT_NET_API
#ifdef __cplusplus
}
#endif
Upvotes: 1