GitHub user simonsouth opened a pull request:
https://github.com/apache/thrift/pull/576
THRIFT-3285 c glib build library with all warnings enabled
These changes
- Update the C (GLib) library's makefile so the AM_CPPFLAGS and AM_CFLAGS
variables are used correctly according to automake's documentation,
- Enable the same compiler warnings enabled during the C++-library build,
and
- Update portions of the library so it will build without generating any
compiler warnings.
The changes to the library itself comprise
- Moving variable declarations to the top of every code block,
- Using unions instead of type-punning to obey strict-aliasing rules,
- Replacing variable-length array declarations with arrays allocated on the
stack (using g_newa and g_alloca),
- Casting void pointers to a suitably sized data type before performing
arithmetic on them,
- Replacing C++-style ("//") comments with C-style equivalents, and
- Removing an errant semicolon and comma.
Applying these changes should allow us to also close THRIFT-2795,
"thrift_binary_protocol.c: 'dereferencing type-punned pointer will break
strict-aliasing rules'".
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/simonsouth/thrift
thrift-3285-c_glib-build-library-with-all-warnings-enabled
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/576.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #576
----
commit 231a33cbfa5c81ab8efd8cbc54bb083d3ed2368d
Author: Simon South <[email protected]>
Date: 2015-08-01T17:00:50Z
c_glib: Library: Use AM_CPPFLAGS for include paths, not AM_CFLAGS
This follows the description of the two variables in the automake
documentation.
commit d4919d5dd17943ff45996566de8146d279930eaf
Author: Simon South <[email protected]>
Date: 2015-08-01T17:05:08Z
c_glib: Library: Build with all warnings enabled
This matches the settings ("-Wall -Wextra -pedantic") used to build
the C++ library.
commit 1e3114c68d22972dd2e559c73cf0adaa0e25bd05
Author: Simon South <[email protected]>
Date: 2015-08-01T18:33:20Z
c_glib: Library: Build without compiler warnings
These changes allow the C (GLib) library to be built without
warnings from the compiler, even with extra compiler warnings
enabled. The changes involve
- Moving variable declarations to the top of every code block,
- Using unions instead of type-punning to follow strict-aliasing
rules,
- Replacing variable-length array declarations with arrays
allocated on the stack (using g_newa and g_alloca),
- Casting void pointers to a suitably sized data type before
performing arithmetic on them,
- Replacing C++-style ("//") comments with C-style equivalents,
and
- Removing an errant semicolon and comma.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---