[CDRIVER-831] GCC 5 warnings Created: 07/Sep/15  Updated: 11/Jan/16  Resolved: 23/Oct/15

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.3.0-beta0

Type: Bug Priority: Minor - P4
Reporter: Jeroen Ooms [X] Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CDRIVER-643 Solaris Compiler warning Closed
related to CDRIVER-664 GCC 5 build & test in Evergreen Closed

 Description   

A few days ago Debian testing changed to use GCC 5 (actually, 5.2 with
the new C++11 ABI used by default). I now get

* checking whether package ‘mongolite’ can be installed ... [14s/17s] WARNING
Found the following significant warnings:
  bson/bson-macros.h:208:19: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  bson/bson-macros.h:194:19: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  bson/bson.c:752:22: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  mongoc/mongoc-bulk-operation.c:252:23: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  mongoc/mongoc-bulk-operation.c:295:29: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  mongoc/mongoc-bulk-operation.c:338:29: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  mongoc/mongoc-util-private.h:31:43: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  mongoc/mongoc-cursor.c:932:22: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  mongoc/mongoc-uri.c:980:22: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]



 Comments   
Comment by Githook User [ 11/Jan/16 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-831: _FUNCTION_ vs _func_
Branch: 1.3.0-dev
https://github.com/mongodb/libbson/commit/b378a6696953440b0a8f4d60b4feac93267734df

Comment by Githook User [ 11/Jan/16 ]

Author:

{u'username': u'jeroenooms', u'name': u'Jeroen Ooms', u'email': u'jeroenooms@gmail.com'}

Message: CDRIVER-831: Avoid non-standard _FUNCTION_ under c99 std
Branch: 1.3.0-dev
https://github.com/mongodb/libbson/commit/ff28c22074df08142af3acc2ca6f48bb710f99ce

Comment by Githook User [ 28/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-831: fix typo in ifdef
Branch: master
https://github.com/mongodb/libbson/commit/d7bc3bd01f38cfd14fde30e1cc9dd4b95ae2d12d

Comment by Githook User [ 28/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-831: fix typo in ifdef
Branch: master
https://github.com/mongodb/libbson/commit/de7a963bd358b85d93fb45b92e441d3d9313fa65

Comment by Githook User [ 28/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-831: MSVC doesn't appear to support _func_
Branch: master
https://github.com/mongodb/libbson/commit/de3fea70f06087d1954e7980e0a116ed24852e09

Comment by Hannes Magnusson [ 23/Oct/15 ]

Thanks!

Comment by Githook User [ 23/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: Bump libbson after adding BSON_FUNC for CDRIVER-831
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/32c34369794f5d27219aa6a40ca608c716fa7505

Comment by Githook User [ 23/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-831: _FUNCTION_ vs _func_
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/92989080764600a29ddd1b4d434329c218c8ca6c

Comment by Githook User [ 23/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-831: _FUNCTION_ vs _func_
Branch: master
https://github.com/mongodb/libbson/commit/b378a6696953440b0a8f4d60b4feac93267734df

Comment by Githook User [ 23/Oct/15 ]

Author:

{u'username': u'jeroenooms', u'name': u'Jeroen Ooms', u'email': u'jeroenooms@gmail.com'}

Message: CDRIVER-831: Avoid non-standard _FUNCTION_ under c99 std
Branch: master
https://github.com/mongodb/libbson/commit/ff28c22074df08142af3acc2ca6f48bb710f99ce

Comment by Jeroen Ooms [X] [ 16/Oct/15 ]

PR at https://github.com/mongodb/libbson/pull/141

Comment by A. Jesse Jiryu Davis [ 07/Sep/15 ]

The driver needs to compile under all conceivable configurations: C89, C99, C++, Microsoft, GCC 4, GCC 5, Clang, ....

It seems like something like this is best, in bson-macros.h in the libbson repo on the 1.3.0-dev branch:

#if __STDC_VERSION__ < 199901L
#  define BSON_FUNC __FUNCTION__
#else
#  define BSON_FUNC __func__
#endif

... and replace "__FUNCTION__" with "BSON_FUNC" everywhere in libbson. Once we've got that working, we can use BSON_FUNC in mongo-c-driver too, also on the 1.3.0-dev branch.

Comment by Jeroen Ooms [X] [ 07/Sep/15 ]

What approach should I take? Replace all occurences of

__FUNCTION__ 

with

_func_ 

?

Comment by A. Jesse Jiryu Davis [ 07/Sep/15 ]

Thanks Jeroen, would you like to submit a pull request?

Comment by Jeroen Ooms [X] [ 07/Sep/15 ]

This issue is actually documented in the porting to gcc 5 manual under "New Warnings":

Several new warnings have been added to the C front end. Among others -Wpedantic now warns about non-standard predefined identifiers.

The fix is either to use the standard predefined identifier _func_ (since C99), or to use the _extension_ keyword:

  const char *s = __extension__ __FUNCTION__;

Generated at Wed Feb 07 21:10:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.