After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 792720 - [PATCH] Don't put includes inside the main function
[PATCH] Don't put includes inside the main function
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
2.24.x
Other FreeBSD
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2018-01-20 09:52 UTC by Ting-Wei Lan
Modified: 2018-01-20 12:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
configure: Move all includes to the first argument of AC_TRY_LINK (1.25 KB, patch)
2018-01-20 09:58 UTC, Ting-Wei Lan
committed Details | Review

Description Ting-Wei Lan 2018-01-20 09:52:35 UTC
In configure.ac, there is a check for iswalnum:

# The following is necessary for Linux libc-5.4.38  
AC_MSG_CHECKING(if iswalnum() and friends are properly defined)  
AC_TRY_LINK([#include <stdlib.h>],[  
#if (defined(HAVE_WCTYPE_H) || defined(HAVE_WCHAR_H))  
#  ifdef HAVE_WCTYPE_H  
#    include <wctype.h>  
#  else  
#    ifdef HAVE_WCHAR_H  
#      include <wchar.h>  
#    endif  
#  endif  
#else  
#  define iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))  
#endif  
iswalnum((wchar_t) 0);  
], gdk_working_wctype=yes, gdk_working_wctype=no)

The second argument of AC_TRY_LINK is the content of main function. We cannot include any header inside the main function because definitions of inline functions in headers become nested functions, which is not supported by clang.
Comment 1 Ting-Wei Lan 2018-01-20 09:58:00 UTC
Created attachment 367144 [details] [review]
configure: Move all includes to the first argument of AC_TRY_LINK

Putting includes in the second argument of AC_TRY_LINK is not safe. If
a header having inline functions is included inside the main function,
it becomes a nested function. This is not supported by clang.
Comment 2 Emmanuele Bassi (:ebassi) 2018-01-20 10:57:54 UTC
Review of attachment 367144 [details] [review]:

Okay
Comment 3 Ting-Wei Lan 2018-01-20 12:10:05 UTC
Attachment 367144 [details] pushed as c3ededb - configure: Move all includes to the first argument of AC_TRY_LINK