Преглед изворни кода

Use macro shortcuts for extern "C" declarations in the public API

Julius Pfrommer пре 5 година
родитељ
комит
c4217b44e2

+ 3 - 7
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_ */

+ 5 - 8
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 */

+ 3 - 7
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_ */

+ 9 - 8
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_ */

+ 3 - 7
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_ */

+ 16 - 8
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_ */

+ 4 - 6
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_ */

+ 6 - 10
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_ */

+ 3 - 7
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_ */

+ 3 - 9
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 <stdarg.h>
 #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_ */

+ 3 - 7
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_ */

+ 6 - 10
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_ */

+ 3 - 7
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_ */

+ 3 - 7
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_ */

+ 7 - 7
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_ */

+ 4 - 7
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_ */

+ 3 - 7
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_ */

+ 3 - 7
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 */

+ 3 - 7
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_ */

+ 3 - 8
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_ */

+ 2 - 6
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_ */

+ 3 - 7
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_ */

+ 2 - 6
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_ */

+ 3 - 7
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_ */

+ 2 - 6
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_ */

+ 2 - 6
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_ */

+ 4 - 8
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_ */

+ 4 - 8
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_ */

+ 3 - 8
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_ */

+ 9 - 14
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())
 
 ###########################

+ 2 - 6
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()))