From c4217b44e2708e40b054b959b8b75e9770c2a7bb Mon Sep 17 00:00:00 2001 From: Julius Pfrommer Date: Thu, 2 Aug 2018 07:56:15 +0200 Subject: [PATCH] Use macro shortcuts for extern "C" declarations in the public API --- include/ua_client.h | 10 +++------ include/ua_client_config.h | 13 +++++------ include/ua_client_highlevel.h | 10 +++------ include/ua_client_highlevel_async.h | 17 ++++++++------- include/ua_client_subscriptions.h | 10 +++------ include/ua_config.h.in | 24 ++++++++++++++------- include/ua_constants.h | 10 ++++----- include/ua_plugin_access_control.h | 16 ++++++-------- include/ua_plugin_history_data_service.h | 10 +++------ include/ua_plugin_log.h | 12 +++-------- include/ua_plugin_network.h | 10 +++------ include/ua_plugin_nodestore.h | 16 ++++++-------- include/ua_plugin_pki.h | 10 +++------ include/ua_plugin_pubsub.h | 10 +++------ include/ua_plugin_securitypolicy.h | 14 ++++++------ include/ua_server.h | 11 ++++------ include/ua_server_config.h | 10 +++------ include/ua_server_pubsub.h | 10 +++------ include/ua_types.h | 10 +++------ include/ua_util.h | 11 +++------- plugins/ua_accesscontrol_default.h | 8 ++----- plugins/ua_config_default.h | 10 +++------ plugins/ua_log_stdout.h | 8 ++----- plugins/ua_network_pubsub_udp.h | 10 +++------ plugins/ua_nodestore_default.h | 8 ++----- plugins/ua_pki_certificate.h | 8 ++----- plugins/ua_securitypolicy_basic128rsa15.h | 12 ++++------- plugins/ua_securitypolicy_basic256sha256.h | 12 ++++------- plugins/ua_securitypolicy_none.h | 11 +++------- tools/generate_datatypes.py | 23 ++++++++------------ tools/nodeset_compiler/backend_open62541.py | 8 ++----- 31 files changed, 129 insertions(+), 233 deletions(-) diff --git a/include/ua_client.h b/include/ua_client.h index 003b08960..a90b6f1fb 100644 --- a/include/ua_client.h +++ b/include/ua_client.h @@ -17,10 +17,6 @@ #ifndef UA_CLIENT_H_ #define UA_CLIENT_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_types.h" #include "ua_types_generated.h" #include "ua_types_generated_handling.h" @@ -30,6 +26,8 @@ extern "C" { #include "ua_client_config.h" #include "ua_nodeids.h" +_UA_BEGIN_DECLS + /** * .. _client: * @@ -463,8 +461,6 @@ __UA_Client_AsyncServiceEx(UA_Client *client, const void *request, * client_highlevel * client_subscriptions */ -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_CLIENT_H_ */ diff --git a/include/ua_client_config.h b/include/ua_client_config.h index 785bbc9c2..e6eadb831 100644 --- a/include/ua_client_config.h +++ b/include/ua_client_config.h @@ -9,12 +9,11 @@ #ifndef UA_CLIENT_CONFIG_H #define UA_CLIENT_CONFIG_H -#ifdef __cplusplus -extern "C" { -#endif - +#include "ua_config.h" #include "ua_plugin_network.h" +_UA_BEGIN_DECLS + /** * .. _client-config: * @@ -138,15 +137,13 @@ typedef struct UA_ClientConfig { /* 0 = background task disabled */ UA_UInt16 outStandingPublishRequests; #endif + /** * connectivity check interval in ms * 0 = background task disabled */ UA_UInt32 connectivityCheckInterval; } UA_ClientConfig; -#ifdef __cplusplus -} -#endif - +_UA_END_DECLS #endif /* UA_CLIENT_CONFIG_H */ diff --git a/include/ua_client_highlevel.h b/include/ua_client_highlevel.h index 95f822e8e..714f1eba7 100644 --- a/include/ua_client_highlevel.h +++ b/include/ua_client_highlevel.h @@ -13,12 +13,10 @@ #ifndef UA_CLIENT_HIGHLEVEL_H_ #define UA_CLIENT_HIGHLEVEL_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_client.h" +_UA_BEGIN_DECLS + /** * .. _client-highlevel: * @@ -590,8 +588,6 @@ UA_StatusCode UA_EXPORT UA_Client_forEachChildNodeCall(UA_Client *client, UA_NodeId parentNodeId, UA_NodeIteratorCallback callback, void *handle) ; -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_CLIENT_HIGHLEVEL_H_ */ diff --git a/include/ua_client_highlevel_async.h b/include/ua_client_highlevel_async.h index 1a98bbf29..7d95c9767 100644 --- a/include/ua_client_highlevel_async.h +++ b/include/ua_client_highlevel_async.h @@ -2,15 +2,16 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * + * Copyright 2018 (c) Thomas Stalder, Blue Time Concept SA + * Copyright 2018 (c) Fraunhofer IOSB (Author: Julius Pfrommer) */ #ifndef UA_CLIENT_HIGHLEVEL_ASYNC_H_ #define UA_CLIENT_HIGHLEVEL_ASYNC_H_ + #include "ua_client.h" -#ifdef __cplusplus -extern "C" { -#endif +_UA_BEGIN_DECLS /** * Raw Services @@ -613,9 +614,10 @@ static UA_INLINE UA_StatusCode UA_Client_addMethodNode_async(UA_Client *client, /** * Misc Functionalities - * ^^^^^^^^^^^^^^ */ + * ^^^^^^^^^^^^^^^^^^^^ */ -UA_StatusCode UA_EXPORT __UA_Client_translateBrowsePathsToNodeIds_async( +UA_StatusCode UA_EXPORT +__UA_Client_translateBrowsePathsToNodeIds_async( UA_Client *client, char *paths[], UA_UInt32 ids[], size_t pathSize, UA_ClientAsyncServiceCallback callback, void *userdata, UA_UInt32 *reqId); @@ -623,6 +625,7 @@ UA_StatusCode UA_EXPORT __UA_Client_translateBrowsePathsToNodeIds_async( typedef void (*UA_ClientAsyncTranslateCallback)(UA_Client *client, void *userdata, UA_UInt32 requestId, UA_TranslateBrowsePathsToNodeIdsResponse *tr); + static UA_INLINE UA_StatusCode UA_Cient_translateBrowsePathsToNodeIds_async( UA_Client *client, char **paths, UA_UInt32 *ids, size_t pathSize, UA_ClientAsyncTranslateCallback callback, void *userdata, @@ -631,8 +634,6 @@ static UA_INLINE UA_StatusCode UA_Cient_translateBrowsePathsToNodeIds_async( pathSize, (UA_ClientAsyncServiceCallback) callback, userdata, reqId); } -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_CLIENT_HIGHLEVEL_ASYNC_H_ */ diff --git a/include/ua_client_subscriptions.h b/include/ua_client_subscriptions.h index 0101a8eeb..f650a9008 100644 --- a/include/ua_client_subscriptions.h +++ b/include/ua_client_subscriptions.h @@ -5,12 +5,10 @@ #ifndef UA_CLIENT_SUBSCRIPTIONS_H_ #define UA_CLIENT_SUBSCRIPTIONS_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_client.h" +_UA_BEGIN_DECLS + #ifdef UA_ENABLE_SUBSCRIPTIONS /** @@ -203,8 +201,6 @@ UA_Client_MonitoredItems_setTriggering(UA_Client *client, #endif -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_CLIENT_SUBSCRIPTIONS_H_ */ diff --git a/include/ua_config.h.in b/include/ua_config.h.in index 0bd421b29..898c8dd5f 100644 --- a/include/ua_config.h.in +++ b/include/ua_config.h.in @@ -5,10 +5,6 @@ #ifndef UA_CONFIG_H_ #define UA_CONFIG_H_ -#ifdef __cplusplus -extern "C" { -#endif - /** * open62541 Version * ----------------- */ @@ -68,6 +64,22 @@ extern "C" { * import symbols from a DLL.*/ #cmakedefine UA_DYNAMIC_LINKING +/* Shortcuts for extern "C" declarations */ +#if !defined(_UA_BEGIN_DECLS) +# ifdef __cplusplus +# define _UA_BEGIN_DECLS extern "C" { +# else +# define _UA_BEGIN_DECLS +# endif +#endif +#if !defined(_UA_END_DECLS) +# ifdef __cplusplus +# define _UA_END_DECLS } +# else +# define _UA_END_DECLS +# endif +#endif + /* Select default architecture if non is selected through CMake or compiler define */ #if ${UA_ARCHITECTURES_NODEF} # ifdef _WIN32 @@ -79,8 +91,4 @@ extern "C" { #include "ua_architecture.h" -#ifdef __cplusplus -} // extern "C" -#endif - #endif /* UA_CONFIG_H_ */ diff --git a/include/ua_constants.h b/include/ua_constants.h index 1c1f056a3..454e61a71 100644 --- a/include/ua_constants.h +++ b/include/ua_constants.h @@ -11,9 +11,9 @@ #ifndef UA_CONSTANTS_H_ #define UA_CONSTANTS_H_ -#ifdef __cplusplus -extern "C" { -#endif +#include "ua_config.h" + +_UA_BEGIN_DECLS /** * Standard-Defined Constants @@ -96,8 +96,6 @@ typedef enum { #define UA_WRITEMASK_WRITEMASK (0x01<<20) #define UA_WRITEMASK_VALUEFORVARIABLETYPE (0x01<<21) -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_CONSTANTS_H_ */ diff --git a/include/ua_plugin_access_control.h b/include/ua_plugin_access_control.h index 764943a37..a65310e45 100644 --- a/include/ua_plugin_access_control.h +++ b/include/ua_plugin_access_control.h @@ -9,12 +9,13 @@ #ifndef UA_PLUGIN_ACCESS_CONTROL_H_ #define UA_PLUGIN_ACCESS_CONTROL_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_types.h" +_UA_BEGIN_DECLS + +struct UA_AccessControl; +typedef struct UA_AccessControl UA_AccessControl; + /** * .. _access-control: * @@ -23,9 +24,6 @@ extern "C" { * The access control callback is used to authenticate sessions and grant access * rights accordingly. */ -struct UA_AccessControl; -typedef struct UA_AccessControl UA_AccessControl; - struct UA_AccessControl { void *context; void (*deleteMembers)(UA_AccessControl *ac); @@ -92,8 +90,6 @@ struct UA_AccessControl { const UA_DeleteReferencesItem *item); }; -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_PLUGIN_ACCESS_CONTROL_H_ */ diff --git a/include/ua_plugin_history_data_service.h b/include/ua_plugin_history_data_service.h index 584eef1d6..fda7e08d7 100644 --- a/include/ua_plugin_history_data_service.h +++ b/include/ua_plugin_history_data_service.h @@ -8,13 +8,11 @@ #ifndef UA_PLUGIN_HISTORY_DATA_SERVICE_H_ #define UA_PLUGIN_HISTORY_DATA_SERVICE_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_types.h" #include "ua_server.h" +_UA_BEGIN_DECLS + struct UA_HistoryDataService; typedef struct UA_HistoryDataService UA_HistoryDataService; @@ -82,8 +80,6 @@ struct UA_HistoryDataService { // For example for read_event, read_modified, read_processed, read_at_time }; -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_PLUGIN_HISTORY_DATA_SERVICE_H_ */ diff --git a/include/ua_plugin_log.h b/include/ua_plugin_log.h index 8dfa0a009..80213eb42 100644 --- a/include/ua_plugin_log.h +++ b/include/ua_plugin_log.h @@ -9,17 +9,14 @@ #ifndef UA_PLUGIN_LOG_H_ #define UA_PLUGIN_LOG_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include #include "ua_config.h" - #include "ua_types.h" #include "ua_types_generated_handling.h" #include "base64.h" +_UA_BEGIN_DECLS + /** * Logging Plugin API * ================== @@ -111,9 +108,6 @@ UA_LOG_FATAL(UA_Logger logger, UA_LogCategory category, const char *msg, ...) { #endif } - -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_PLUGIN_LOG_H_ */ diff --git a/include/ua_plugin_network.h b/include/ua_plugin_network.h index 08274792f..46a389aba 100644 --- a/include/ua_plugin_network.h +++ b/include/ua_plugin_network.h @@ -9,13 +9,11 @@ #ifndef UA_PLUGIN_NETWORK_H_ #define UA_PLUGIN_NETWORK_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_server.h" #include "ua_plugin_log.h" +_UA_BEGIN_DECLS + /* Forward declarations */ struct UA_Connection; typedef struct UA_Connection UA_Connection; @@ -201,8 +199,6 @@ typedef UA_Connection (*UA_ConnectClientConnection)(UA_ConnectionConfig localConf, const char *endpointUrl, const UA_UInt32 timeout, UA_Logger logger); -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_PLUGIN_NETWORK_H_ */ diff --git a/include/ua_plugin_nodestore.h b/include/ua_plugin_nodestore.h index 1d8860fce..0dfbb8acd 100644 --- a/include/ua_plugin_nodestore.h +++ b/include/ua_plugin_nodestore.h @@ -17,18 +17,16 @@ * not meant to be used directly by end users. Please use the public server API * / OPC UA services to interact with the information model. */ -#ifdef __cplusplus -extern "C" { -#endif - +#include "ua_types.h" #include "ua_server.h" + +_UA_BEGIN_DECLS + +/* Forward declaration */ #ifdef UA_ENABLE_SUBSCRIPTIONS_EVENTS -/* forward declaration */ struct UA_MonitoredItem; #endif -#include "ua_types.h" - /** * .. _information-modelling: * @@ -529,8 +527,6 @@ UA_Node_deleteReferences(UA_Node *node); void UA_EXPORT UA_Node_deleteMembers(UA_Node *node); -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_SERVER_NODES_H_ */ diff --git a/include/ua_plugin_pki.h b/include/ua_plugin_pki.h index b48f088c6..a4b9f6767 100644 --- a/include/ua_plugin_pki.h +++ b/include/ua_plugin_pki.h @@ -8,13 +8,11 @@ #ifndef UA_PLUGIN_PKI_H_ #define UA_PLUGIN_PKI_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_types.h" #include "ua_server.h" +_UA_BEGIN_DECLS + /** * Public Key Infrastructure Integration * ===================================== @@ -51,8 +49,6 @@ struct UA_CertificateVerification { void (*deleteMembers)(UA_CertificateVerification *cv); }; -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_PLUGIN_PKI_H_ */ diff --git a/include/ua_plugin_pubsub.h b/include/ua_plugin_pubsub.h index 758190eb4..9a59b34e5 100644 --- a/include/ua_plugin_pubsub.h +++ b/include/ua_plugin_pubsub.h @@ -8,12 +8,10 @@ #ifndef UA_PLUGIN_PUBSUB_H_ #define UA_PLUGIN_PUBSUB_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_server_pubsub.h" +_UA_BEGIN_DECLS + #ifdef UA_ENABLE_PUBSUB /** @@ -90,8 +88,6 @@ typedef struct UA_PubSubTransportLayer{ #endif /* UA_ENABLE_PUBSUB */ -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_PLUGIN_PUBSUB_H_ */ diff --git a/include/ua_plugin_securitypolicy.h b/include/ua_plugin_securitypolicy.h index a2be6b7b4..523a91d58 100644 --- a/include/ua_plugin_securitypolicy.h +++ b/include/ua_plugin_securitypolicy.h @@ -10,20 +10,22 @@ #ifndef UA_PLUGIN_SECURITYPOLICY_H_ #define UA_PLUGIN_SECURITYPOLICY_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_types.h" #include "ua_types_generated.h" #include "ua_plugin_log.h" #include "ua_plugin_pki.h" +_UA_BEGIN_DECLS + extern const UA_ByteString UA_SECURITY_POLICY_NONE_URI; struct UA_SecurityPolicy; typedef struct UA_SecurityPolicy UA_SecurityPolicy; +/** + * SecurityPolicy Interface Definition + * ----------------------------------- */ + typedef struct { UA_String uri; @@ -385,8 +387,6 @@ typedef UA_StatusCode (*UA_SecurityPolicy_Func)(UA_SecurityPolicy *policy, const UA_ByteString localPrivateKey, UA_Logger logger); -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_PLUGIN_SECURITYPOLICY_H_ */ diff --git a/include/ua_server.h b/include/ua_server.h index 23265203c..e7df99df3 100644 --- a/include/ua_server.h +++ b/include/ua_server.h @@ -13,15 +13,14 @@ #ifndef UA_SERVER_H_ #define UA_SERVER_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_types.h" #include "ua_types_generated.h" #include "ua_types_generated_handling.h" #include "ua_nodeids.h" +_UA_BEGIN_DECLS + +/* Forward declarations */ struct UA_ServerConfig; typedef struct UA_ServerConfig UA_ServerConfig; @@ -1263,8 +1262,6 @@ UA_StatusCode UA_EXPORT UA_Server_getNamespaceByName(UA_Server *server, const UA_String namespaceUri, size_t* foundIndex); -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_SERVER_H_ */ diff --git a/include/ua_server_config.h b/include/ua_server_config.h index 26a1f315e..0d641aac2 100644 --- a/include/ua_server_config.h +++ b/include/ua_server_config.h @@ -11,10 +11,6 @@ #ifndef UA_SERVER_CONFIG_H_ #define UA_SERVER_CONFIG_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_server.h" #include "ua_plugin_log.h" #include "ua_plugin_network.h" @@ -31,6 +27,8 @@ extern "C" { #include "ua_plugin_history_data_service.h" #endif +_UA_BEGIN_DECLS + /** * .. _server-configuration: * @@ -215,8 +213,6 @@ struct UA_ServerConfig { #endif }; -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_SERVER_CONFIG_H_ */ diff --git a/include/ua_server_pubsub.h b/include/ua_server_pubsub.h index 9f8aa5374..d255e60cb 100644 --- a/include/ua_server_pubsub.h +++ b/include/ua_server_pubsub.h @@ -8,12 +8,10 @@ #ifndef UA_SERVER_PUBSUB_H #define UA_SERVER_PUBSUB_H -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_server.h" +_UA_BEGIN_DECLS + #ifdef UA_ENABLE_PUBSUB /** @@ -349,8 +347,6 @@ UA_Server_removeDataSetWriter(UA_Server *server, const UA_NodeId dsw); #endif /* UA_ENABLE_PUBSUB */ -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_SERVER_PUBSUB_H */ diff --git a/include/ua_types.h b/include/ua_types.h index 017afaa83..68248b4ea 100644 --- a/include/ua_types.h +++ b/include/ua_types.h @@ -16,14 +16,12 @@ #ifndef UA_TYPES_H_ #define UA_TYPES_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_config.h" #include "ua_constants.h" #include "ua_statuscodes.h" +_UA_BEGIN_DECLS + #define UA_BUILTIN_TYPES_COUNT 25U /** @@ -942,8 +940,6 @@ UA_Guid UA_EXPORT UA_Guid_random(void); /* no cryptographic entropy */ * * types_generated */ -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_TYPES_H_ */ diff --git a/include/ua_util.h b/include/ua_util.h index d51e2ea81..dcf955724 100644 --- a/include/ua_util.h +++ b/include/ua_util.h @@ -9,13 +9,11 @@ #ifndef UA_HELPER_H_ #define UA_HELPER_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_config.h" #include "ua_types.h" +_UA_BEGIN_DECLS + /** * Endpoint URL Parser * ------------------- @@ -76,9 +74,6 @@ UA_ByteString_toBase64String(const UA_ByteString *byteString, UA_String *str); UA_StatusCode UA_EXPORT UA_NodeId_toString(const UA_NodeId *nodeId, UA_String *nodeIdStr); - -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_HELPER_H_ */ diff --git a/plugins/ua_accesscontrol_default.h b/plugins/ua_accesscontrol_default.h index 4f7b2c9ab..9be0af4d3 100644 --- a/plugins/ua_accesscontrol_default.h +++ b/plugins/ua_accesscontrol_default.h @@ -11,9 +11,7 @@ #include "ua_server.h" #include "ua_plugin_access_control.h" -#ifdef __cplusplus -extern "C" { -#endif +_UA_BEGIN_DECLS typedef struct { UA_String username; @@ -27,8 +25,6 @@ UA_AccessControl_default(UA_Boolean allowAnonymous, size_t usernamePasswordLoginSize, const UA_UsernamePasswordLogin *usernamePasswordLogin); -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_ACCESSCONTROL_DEFAULT_H_ */ diff --git a/plugins/ua_config_default.h b/plugins/ua_config_default.h index d7a1951e3..0d17c1c10 100644 --- a/plugins/ua_config_default.h +++ b/plugins/ua_config_default.h @@ -9,14 +9,12 @@ #ifndef UA_CONFIG_DEFAULT_H_ #define UA_CONFIG_DEFAULT_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_server.h" #include "ua_server_config.h" #include "ua_client.h" +_UA_BEGIN_DECLS + /**********************/ /* Default Connection */ /**********************/ @@ -117,8 +115,6 @@ UA_ServerConfig_delete(UA_ServerConfig *config); extern const UA_EXPORT UA_ClientConfig UA_ClientConfig_default; -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_CONFIG_DEFAULT_H_ */ diff --git a/plugins/ua_log_stdout.h b/plugins/ua_log_stdout.h index 29e86059f..cb556fe5a 100644 --- a/plugins/ua_log_stdout.h +++ b/plugins/ua_log_stdout.h @@ -9,16 +9,12 @@ #include "ua_plugin_log.h" -#ifdef __cplusplus -extern "C" { -#endif +_UA_BEGIN_DECLS void UA_EXPORT UA_Log_Stdout(UA_LogLevel level, UA_LogCategory category, const char *msg, va_list args); -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_LOG_STDOUT_H_ */ diff --git a/plugins/ua_network_pubsub_udp.h b/plugins/ua_network_pubsub_udp.h index 0a3e22a17..07a991298 100644 --- a/plugins/ua_network_pubsub_udp.h +++ b/plugins/ua_network_pubsub_udp.h @@ -7,17 +7,13 @@ #ifndef UA_NETWORK_UDPMC_H_ #define UA_NETWORK_UDPMC_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_plugin_pubsub.h" +_UA_BEGIN_DECLS + UA_PubSubTransportLayer UA_PubSubTransportLayerUDPMP(void); -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_NETWORK_UDPMC_H_ */ diff --git a/plugins/ua_nodestore_default.h b/plugins/ua_nodestore_default.h index 5d9b2fdec..f9c5900d2 100644 --- a/plugins/ua_nodestore_default.h +++ b/plugins/ua_nodestore_default.h @@ -11,16 +11,12 @@ #include "ua_plugin_nodestore.h" -#ifdef __cplusplus -extern "C" { -#endif +_UA_BEGIN_DECLS /* Initializes the nodestore, sets the context and function pointers */ UA_StatusCode UA_EXPORT UA_Nodestore_default_new(UA_Nodestore *ns); -#ifdef __cplusplus -} // extern "C" -#endif +_UA_END_DECLS #endif /* UA_NODESTORE_DEFAULT_H_ */ diff --git a/plugins/ua_pki_certificate.h b/plugins/ua_pki_certificate.h index 8a9ae4415..9ee3a49dc 100644 --- a/plugins/ua_pki_certificate.h +++ b/plugins/ua_pki_certificate.h @@ -9,9 +9,7 @@ #include "ua_plugin_pki.h" -#ifdef __cplusplus -extern "C" { -#endif +_UA_BEGIN_DECLS /* Default implementation that accepts all certificates */ UA_EXPORT void @@ -30,8 +28,6 @@ UA_CertificateVerification_Trustlist(UA_CertificateVerification *cv, #endif -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_PKI_CERTIFICATE_H_ */ diff --git a/plugins/ua_securitypolicy_basic128rsa15.h b/plugins/ua_securitypolicy_basic128rsa15.h index f3484fa35..c0852499e 100644 --- a/plugins/ua_securitypolicy_basic128rsa15.h +++ b/plugins/ua_securitypolicy_basic128rsa15.h @@ -8,13 +8,11 @@ #ifndef UA_SECURITYPOLICY_BASIC128RSA15_H_ #define UA_SECURITYPOLICY_BASIC128RSA15_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_plugin_securitypolicy.h" #include "ua_plugin_log.h" +_UA_BEGIN_DECLS + UA_EXPORT UA_StatusCode UA_SecurityPolicy_Basic128Rsa15(UA_SecurityPolicy *policy, UA_CertificateVerification *certificateVerification, @@ -22,8 +20,6 @@ UA_SecurityPolicy_Basic128Rsa15(UA_SecurityPolicy *policy, const UA_ByteString localPrivateKey, UA_Logger logger); -#ifdef __cplusplus -} -#endif +_UA_END_DECLS -#endif // UA_SECURITYPOLICY_BASIC128RSA15_H_ +#endif /* UA_SECURITYPOLICY_BASIC128RSA15_H_ */ diff --git a/plugins/ua_securitypolicy_basic256sha256.h b/plugins/ua_securitypolicy_basic256sha256.h index 3d9ff561b..a3c0f78bc 100644 --- a/plugins/ua_securitypolicy_basic256sha256.h +++ b/plugins/ua_securitypolicy_basic256sha256.h @@ -9,13 +9,11 @@ #ifndef UA_SECURITYPOLICY_BASIC256SHA256_H_ #define UA_SECURITYPOLICY_BASIC256SHA256_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_plugin_securitypolicy.h" #include "ua_plugin_log.h" +_UA_BEGIN_DECLS + UA_EXPORT UA_StatusCode UA_SecurityPolicy_Basic256Sha256(UA_SecurityPolicy *policy, UA_CertificateVerification *certificateVerification, @@ -23,8 +21,6 @@ UA_SecurityPolicy_Basic256Sha256(UA_SecurityPolicy *policy, const UA_ByteString localPrivateKey, UA_Logger logger); -#ifdef __cplusplus -} -#endif +_UA_END_DECLS -#endif // UA_SECURITYPOLICY_BASIC256SHA256_H_ +#endif /* UA_SECURITYPOLICY_BASIC256SHA256_H_ */ diff --git a/plugins/ua_securitypolicy_none.h b/plugins/ua_securitypolicy_none.h index 9dc3b695e..23c49b3e9 100644 --- a/plugins/ua_securitypolicy_none.h +++ b/plugins/ua_securitypolicy_none.h @@ -8,19 +8,14 @@ #ifndef UA_SECURITYPOLICY_NONE_H_ #define UA_SECURITYPOLICY_NONE_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ua_plugin_securitypolicy.h" -#include "ua_plugin_log.h" + +_UA_BEGIN_DECLS UA_StatusCode UA_EXPORT UA_SecurityPolicy_None(UA_SecurityPolicy *policy, UA_CertificateVerification *certificateVerification, const UA_ByteString localCertificate, UA_Logger logger); -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* UA_SECURITYPOLICY_NONE_H_ */ diff --git a/tools/generate_datatypes.py b/tools/generate_datatypes.py index dabb5e99a..7333963ce 100755 --- a/tools/generate_datatypes.py +++ b/tools/generate_datatypes.py @@ -483,10 +483,6 @@ printh('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + ' #ifndef ''' + outname.upper() + '''_GENERATED_H_ #define ''' + outname.upper() + '''_GENERATED_H_ -#ifdef __cplusplus -extern "C" { -#endif - #ifdef UA_NO_AMALGAMATION #include "ua_types.h" ''' + ('#include "ua_types_generated.h"\n' if outname != "ua_types" else '') + ''' @@ -494,6 +490,8 @@ extern "C" { #include "open62541.h" #endif +_UA_BEGIN_DECLS + ''') filtered_types = iter_types(types) @@ -519,9 +517,9 @@ for t in filtered_types: i += 1 printh(''' -#ifdef __cplusplus -} // extern "C" -#endif\n + +_UA_END_DECLS + #endif /* %s_GENERATED_H_ */''' % outname.upper()) ################## @@ -535,12 +533,10 @@ printf('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + ' #ifndef ''' + outname.upper() + '''_GENERATED_HANDLING_H_ #define ''' + outname.upper() + '''_GENERATED_HANDLING_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "''' + outname + '''_generated.h" +_UA_BEGIN_DECLS + #if defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 6 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wmissing-field-initializers" @@ -557,9 +553,8 @@ printf(''' # pragma GCC diagnostic pop #endif -#ifdef __cplusplus -} // extern "C" -#endif\n +_UA_END_DECLS + #endif /* %s_GENERATED_HANDLING_H_ */''' % outname.upper()) ########################### diff --git a/tools/nodeset_compiler/backend_open62541.py b/tools/nodeset_compiler/backend_open62541.py index 91e5a5573..69fb39496 100644 --- a/tools/nodeset_compiler/backend_open62541.py +++ b/tools/nodeset_compiler/backend_open62541.py @@ -200,15 +200,11 @@ UA_findDataTypeByBinary(const UA_NodeId *typeId); #include "open62541.h" """) writeh(""" -#ifdef __cplusplus -extern "C" { -#endif +_UA_BEGIN_DECLS extern UA_StatusCode %s(UA_Server *server); -#ifdef __cplusplus -} -#endif +_UA_END_DECLS #endif /* %s_H_ */""" % \ (outfilebase, outfilebase.upper()))