[Home]

Summary:ASTERISK-03559: [patch] gcc 2.96 no longer compiles asterisk
Reporter:Steve Hanselman (shanselman)Labels:
Date Opened:2005-02-22 10:08:17.000-0600Date Closed:2008-01-15 15:26:16.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) ivr_struct_compile_rev1.diff.txt
Description:The declaration forast_ivr)options is not accepted by gcc 2.96.

****** STEPS TO REPRODUCE ******

make clean;make on asterisk.

In file included from config.c:34:
include/asterisk/app.h:62: array size missing in `options'
make: *** [config.o] Error 1


****** ADDITIONAL INFORMATION ******

struct ast_ivr_menu {
       char *title;            /* Title of menu */
       unsigned int flags;     /* Flags */
       struct ast_ivr_option options[];        /* All options */
};
Comments:By: Kevin P. Fleming (kpfleming) 2005-02-22 10:18:25.000-0600

"not accepted"? Please post what the compiler complains about, although I bet I can guess: it doesn't like the empty array declaration.

By: Steve Hanselman (shanselman) 2005-02-22 10:21:24.000-0600

Yes, I pasted that into Mantis but it looks as though it's decided to eat some of the text, here it is again...

In file included from config.c:34:
include/asterisk/app.h:62: array size missing in `options'
make: *** [config.o] Error 1

By: Steve Hanselman (shanselman) 2005-02-22 10:22:16.000-0600

And now the text has magically reappeared???

By: Kevin P. Fleming (kpfleming) 2005-02-22 10:32:29.000-0600

Minor patch to fix this uploaded. Thanks for the report!

By: Steve Hanselman (shanselman) 2005-02-22 12:42:26.000-0600

Confirmed fixed.

By: Mark Spencer (markster) 2005-02-22 23:07:12.000-0600

Does this not generate compiler warnings now on app_ivrdemo.o if it's set to compile?  Will it even still operate?

By: Kevin P. Fleming (kpfleming) 2005-02-23 00:20:42.000-0600

Yes, it does. This can be fixed by moving the array out of the structure and having the structure contain a pointer to the array, or you can just declare that you won't support compilers that can't compile the code the way it currently is in CVS HEAD. I wouldn't suggest doing that though, there are lots of compilers out there that can't handle some of these oddball things.

Even though this "flexible array member" syntax is part of C99, statically initalizing them is not, and is a GNU GCC extension that is not implemented by all versions of GCC. in fact, according to the GCC manual, all versions of GCC prior to 3.0 worked using zero-length arrays, and all versions 3.0+ require flexible array syntax.

I suppose a third option would be to declare the array member differently for __GNUC__ < 3.

edited on: 02-23-05 00:26

By: Kevin P. Fleming (kpfleming) 2005-02-24 11:07:10.000-0600

More updates... the empty array syntax is going away with gcc 4.0 as well, so it would be best to not rely on it.

As an alternative, this _may_ work (I have not tried):

struct ast_ivr_menu {
 char *title; /* Title of menu */
 unsigned int flags; /* Flags */
 struct ast_ivr_option *options; /* All options */
};

static struct ast_ivr_menu foobar = {
 .title = "Title",
 .flags = 0,
 .options = {
   { "s", AST..., "start" },
   { NULL },
 },
};

By: Mark Spencer (markster) 2005-02-26 13:08:30.000-0600

Fixed in CVS head with some pre-processor foo worthy of kpfleming!

By: Digium Subversion (svnbot) 2008-01-15 15:26:16.000-0600

Repository: asterisk
Revision: 5091

U   trunk/apps/app_ivrdemo.c
U   trunk/include/asterisk/app.h

------------------------------------------------------------------------
r5091 | markster | 2008-01-15 15:26:15 -0600 (Tue, 15 Jan 2008) | 2 lines

Fix build of new IVR stuff for GCC 2.96 and later gcc's too (bug ASTERISK-3559)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=5091