[asterisk-dev] const char * to AST_STRING_FIELD

Kevin P. Fleming kpfleming at digium.com
Tue Jan 31 17:07:51 CST 2012


On 01/31/2012 12:25 PM, Szasz Tamas wrote:
> Hi,
>
> You are right, the 1.6.2 branch is on end of life, but our configuration
> is for 1.6.2.
> I checked some source code from the version 1.6.2.22 (especially the
> func_cdr and func_odb), in witch i saw that the ast_custom_function is
> used in this format:
> static struct ast_custom_function cdr_function = {
> .name = "CDR",
> .read = cdr_read,
> .write = cdr_write,
> };
> But when i tried in my code, I got these errors at compile time:
> func/FuncStartCall.cpp:48: error: expected primary-expression before ‘.’
> token
> func/FuncStartCall.cpp:48: error: expected primary-expression before ‘.’
> token
> func/FuncStartCall.cpp:48: error: expected primary-expression before ‘.’
> token
> func/FuncStartCall.cpp:48: error: uninitialized const member
> ‘ast_custom_function::desc’
> func/FuncStartCall.cpp:48: error: uninitialized const member
> ‘ast_custom_function::syntax’
> func/FuncStartCall.cpp:48: error: uninitialized const member
> ‘ast_custom_function::arguments’
> func/FuncStartCall.cpp:48: error: uninitialized const member
> ‘ast_custom_function::seealso’

Your module appears to be written in C++ (the .cpp source file 
extensions), and you cannot use that named-initializer syntax in C++. In 
your code, you will have to just initialize the structure members in 
order, without names (which also means you must start with the first 
member and you can't skip any). This is one area of C++ that is a bit 
inelegant.

-- 
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
Jabber: kfleming at digium.com | SIP: kpfleming at digium.com | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at www.digium.com & www.asterisk.org



More information about the asterisk-dev mailing list