[asterisk-dev] const char * to AST_STRING_FIELD

Szasz Tamas szasz.tamas at elastoffice.com
Wed Feb 1 01:01:26 CST 2012


On 2/1/12 6:17 AM, asterisk-dev-request at lists.digium.com 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

Yes, it is written in C++. I tried in that format what you have 
explained. This is why I ask for help on the list (Because I can't 
figure out witch is the correct format of the struct in this situation - 
the black spot is around the "AST_DECLARE_STRING_FIELDS"). Maybe 
somebody can give me a simple example with the correct format in C++?

Thanks for help, and sorry for noob questions.

Regards



More information about the asterisk-dev mailing list