[Asterisk-code-review] app.h: Restore C++ compatibility for macro AST_DECLARE_APP_ARGS (asterisk[master])

Jean Aunis - Prescom asteriskteam at digium.com
Tue Feb 9 10:26:33 CST 2021


Jean Aunis - Prescom has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15399 )


Change subject: app.h: Restore C++ compatibility for macro AST_DECLARE_APP_ARGS
......................................................................

app.h: Restore C++ compatibility for macro AST_DECLARE_APP_ARGS

C++ does not support struct definition inside sizeof(). To get around this,
AST_DECLARE_APP_ARGS must be given an explicit argument count when compiling
for C++.

ASTERISK-29287

Change-Id: Ibb299334d527fcd2af2b023fe64925ecece77d6d
---
M include/asterisk/app.h
1 file changed, 15 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/99/15399/1

diff --git a/include/asterisk/app.h b/include/asterisk/app.h
index 91d06aa..5ddbf4e 100644
--- a/include/asterisk/app.h
+++ b/include/asterisk/app.h
@@ -1215,7 +1215,11 @@
   ast_app_separate_args() will perform that function before parsing
   the arguments.
  */
+#if defined(__cplusplus) || defined(c_plusplus)
+#define AST_DECLARE_APP_ARGS(name, arglist, argcount) AST_DEFINE_APP_ARGS_TYPE(, arglist, argcount) name = { 0, }
+#else
 #define AST_DECLARE_APP_ARGS(name, arglist) AST_DEFINE_APP_ARGS_TYPE(, arglist) name = { 0, }
+#endif
 
 /*!
   \brief Define a structure type to hold an application's arguments.
@@ -1231,7 +1235,16 @@
   \note This defines a structure type, but does not declare an instance
   of the structure. That must be done separately.
  */
-
+#if defined(__cplusplus) || defined(c_plusplus)
+#define AST_DEFINE_APP_ARGS_TYPE(type, arglist, argcount) \
+	struct type { \
+		unsigned int argc; \
+		union { \
+			char *argv[argcount]; \
+			struct {arglist}; \
+		}; \
+	}
+#else
 #define AST_DEFINE_APP_ARGS_TYPE(type, arglist) \
 	struct type { \
 		unsigned int argc; \
@@ -1240,6 +1253,7 @@
 			struct {arglist}; \
 		}; \
 	}
+#endif
 
 /*!
   \brief Performs the 'standard' argument separation process for an application.

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15399
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ibb299334d527fcd2af2b023fe64925ecece77d6d
Gerrit-Change-Number: 15399
Gerrit-PatchSet: 1
Gerrit-Owner: Jean Aunis - Prescom <jean.aunis at prescom.fr>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210209/f711a0ed/attachment.html>


More information about the asterisk-code-review mailing list