Struct ast_channel: forward declaration / incomplete definition of type

I have a problem when compiling chan_dongle. (GitHub - bg111/asterisk-chan-dongle: Automatically exported from code.google.com/p/asterisk-chan-dongle) The compiler (clang) doesn’t like how the structure ast_channel is described.

cc -fblocks -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self -O3 -O6 -I.  -D_GNU_SOURCE -I/usr/ports/net/asterisk18/work/asterisk-18.21.0/include -I/usr/include -DHAVE_CONFIG_H  -fvisibility=hidden -fPIC -Wall -Wextra -MD -MT at_response.o -MF .at_response.o.d -MP  -o at_response.o -c at_response.c
warning: optimization level '-O6' is not supported; using '-O3' instead
at_response.c:854:16: error: incomplete definition of type 'struct ast_channel'
        cpvt = channel->tech_pvt;
               ~~~~~~~^
/usr/ports/net/asterisk18/work/asterisk-18.21.0/include/asterisk.h:206:8: note: forward declaration of 'struct ast_channel'
struct ast_channel;
       ^
at_response.c:861:10: error: incomplete definition of type 'struct ast_channel'
                channel->tech_pvt = NULL;
                ~~~~~~~^
/usr/ports/net/asterisk18/work/asterisk-18.21.0/include/asterisk.h:206:8: note: forward declaration of 'struct ast_channel'
struct ast_channel;
       ^
at_response.c:923:23: error: incomplete definition of type 'struct ast_channel'
                                                                        cpvt->channel->rings += pvt->rings;
                                                                        ~~~~~~~~~~~~~^
/usr/ports/net/asterisk18/work/asterisk-18.21.0/include/asterisk.h:206:8: note: forward declaration of 'struct ast_channel'
struct ast_channel;
       ^
1 warning and 3 errors generated.
gmake: *** [Makefile:65: at_response.o] Error 1

I haven’t found a description of this structure anywhere.
How can I solve this problem?

I would be grateful for recommendations,
Ogogon.

chan_dongle is third party code and no longer supported by its creator. It should not be used for anything missing critical.

The channel structure is defined in include/asterisk/channel.h. However note that it is possible that chan_dongle predates a big structural change in which most accesses to this structure were hidden behind methods, and you may have a major rewrite on your hands.

struct ast_channel contains all the driver independent information for a channel. ->tech_pvt is a pointer to a driver dependent structure that contains information about the state of the channel in the driver currently using that channel.

These are very key constructs in Asterisk internals, so anyone maintaining third party code needs to be familiar with them.

I apologize, but it is possible that you are confusing something.
In Asterisk version asterisk-18.21.0, in the file include/asterisk/channel.h, this structure is defined more than provisionally.

struct ast_channel;

(Line #952).

Alas, my compiler cannot obtain any useful and necessary information for its operation about the variables that make up the structure from this file.
Therefore, it is quite reasonable to complain about the incomplete definition. There’s nothing to even blame him for…

The only place I found a definition of this structure is in the file main/channel_internal_api.c.
But this is not a header file.

It is completely unclear why this such an important structure is defined not in the header, but in the code file, and what to do in this situation.

The channel structure was made opaque years upon years upon years ago. Access to it is via functions.

My mistake. I didn’t look carefully enough even though I didn’t expect to find it. The tech_pvt I found is a method, not an exposed field. I misread it as a field and assumed that, for some reason, it was still in that header. You basically still have all the fields, but they are functions, not fields.

To use the source code you have, you need to do major upgrades (which I think I also said), or use an obsolete, and unsupported Asterisk along with your unsupported channel driver.

Hm… Thank you. All methods are incredibly exciting…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.