[Home]

Summary:ASTERISK-27629: [patch] headers: Replace typeof with __typeof__.
Reporter:Alexander Traud (traud)Labels:patch
Date Opened:2018-01-27 02:55:38.000-0600Date Closed:
Priority:MinorRegression?
Status:Open/NewComponents:Core/Portability
Versions:13.19.0 15.2.0 Frequency of
Occurrence
Related
Issues:
Environment:DragonFly BSD 5.0.2 with GCC 5.4.1 (default) FreeBSD 11.1 with clang 4.0 (default)Attachments:( 0) typeof_in_headers.patch
Description:The documentation of GCC [states|http://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html#Alternate-Keywords] one should not use {{typeof}} in header files. Instead, {{\_\_typeof\_\_}} should be used. In Asterisk, {{typeof}} is used 117 times in header files. If {{typeof}} is within a DEFINE and referenced only by C code, {{typeof}} is not really used in a header file because it is eliminated by the preprocessor already. Of these 117, only 4 occasions were identified to be used within a header file itself. 3 were directly used and were found by a text search. 1 occasion (utils.h) is a DEFINE which is then used within the function {{ast_alertpipe_swap(.)}}, which is coded in a header file.

These issues were found by compiling {{res_snmp.c}} within FreeBSD 11.1 with its default compiler _clang_ 4.0. Although the root cause is quite obvious, uncertainty remains why these errors happened only with the module {{res_snmp.c}}. These headers are included by other modules before. Therefore, something else in the build system must be wrong, because this got obvious only when trying to compile {{res_snmp.c}} and did not happen with clang 4.0 (and clang 5.0) on Debian, Ubuntu, CentOS, or Fedora.

Workaround: Disable res_snmp via {{menuselect}} or to  remove the package {{net-snmp}} from the installation, for example via {{pkg delete net-snmp}}.
Comments:By: Corey Farrell (coreyfarrell) 2018-01-28 13:33:38.760-0600

Please post the output of {{make NOISY_BUILD=1}} and attach your {{makeopts}} with a .txt extension so we can determine why res_snmp is rejecting GCC extensions on FreeBSD.

By: Alexander Traud (traud) 2018-01-29 04:33:33.024-0600

{{make NOISY_BUILD=1}}, {{makeopts}}, and {{net-snmp-config --cflags}} include {{-std=c99}}. Not sure how to precede from that. Yet, I was not able to find the causing change, neither [in the port|https://svnweb.freebsd.org/ports/head/net-mgmt/net-snmp/?view=log] nor [in the original project|http://net-snmp.sourceforge.net]. But please, double-check. I am not sure, I searched correctly.

By: Corey Farrell (coreyfarrell) 2018-01-29 07:49:37.608-0600

I think maybe {{USE_CSTD=       c99}} at \[1\] is the problem.  It looks like net-snmp-config.in from upstream \[2\] has {{@CFLAGS@}} included in the output for {{net-snmp-config --cflags}}.  I suspect the USE_CSTD ultimately results in something like {{CFLAGS="-std=c99" ./configure}} being used to configure net-snmp.

I do wonder about what other CFLAGS are being set by the FreeBSD net-snmp package.  On Fedora 26 I get:
{noformat}
$ net-snmp-config --cflags
-I. -I/usr/include
{noformat}

I'm unsure how to proceed, like I said on gerrit Asterisk requires GCC extensions.  Would you be willing to report a bug to FreeBSD for the net-snmp package?  If so please cross-link the bugs between here and there.

\[1\] https://svnweb.freebsd.org/ports/head/net-mgmt/net-snmp/Makefile?revision=459281&view=markup#l48
\[2\] https://sourceforge.net/p/net-snmp/code/ci/master/tree/net-snmp-config.in

By: Corey Farrell (coreyfarrell) 2018-01-31 11:45:40.756-0600

Please let us know if you are pursuing this with FreeBSD.  This is not a bug in Asterisk since we explicitly require GCC extensions.

By: Alexander Traud (traud) 2018-02-17 10:12:22.254-0600

See the comment in the change on Gerrit. Currently, the report is within Asterisk. If somebody likes to report further upstream, to the maintainer of that port in FreeBSD, he is welcome.

By: Friendly Automation (friendly-automation) 2018-04-12 09:44:59.398-0500

Change 8723 merged by Jenkins2:
Build System: Strip '-std=c99' from CFLAGS provided by libraries.

[https://gerrit.asterisk.org/8723|https://gerrit.asterisk.org/8723]

By: Friendly Automation (friendly-automation) 2018-04-12 09:53:46.049-0500

Change 8721 merged by Jenkins2:
Build System: Strip '-std=c99' from CFLAGS provided by libraries.

[https://gerrit.asterisk.org/8721|https://gerrit.asterisk.org/8721]

By: Friendly Automation (friendly-automation) 2018-04-12 09:54:20.336-0500

Change 8722 merged by Jenkins2:
Build System: Strip '-std=c99' from CFLAGS provided by libraries.

[https://gerrit.asterisk.org/8722|https://gerrit.asterisk.org/8722]

By: Alexander Traud (traud) 2018-04-17 06:35:07.111-0500

Commenting, so this gets re-opened.

By: Asterisk Team (asteriskteam) 2018-04-17 06:35:07.458-0500

This issue has been reopened as a result of your commenting on it as the reporter. It will be triaged once again as applicable.