Skip to content

enca: fix compiler warnings for GCC with -Wunused-but-set-variable#98

Merged
Syed-Shahrukh-OSSRevival merged 1 commit into
Project-OSS-Revival:masterfrom
heitbaum:patch-1
Apr 28, 2026
Merged

enca: fix compiler warnings for GCC with -Wunused-but-set-variable#98
Syed-Shahrukh-OSSRevival merged 1 commit into
Project-OSS-Revival:masterfrom
heitbaum:patch-1

Conversation

@heitbaum

Copy link
Copy Markdown
Contributor

Variable 'map_created' in xtable() is only used in assert() which is compiled out when -DNDEBUG is defined. Wrap the block in #ifndef NDEBUG to preserve debug-build sanity checking while silencing the warning in release builds.

Variable 'map_created' in xtable() is only used in assert() which is
compiled out when -DNDEBUG is defined. Wrap the block in #ifndef NDEBUG
to preserve debug-build sanity checking while silencing the warning in
release builds.
@Syed-Shahrukh-OSSRevival

Copy link
Copy Markdown
Member

Thank you for your contribution, makes sense.
You can utilize DEBUG.

changelog entry

2003-06-24  David Necas (Yeti) <yeti@physics.muni.cz>
    * lib/internal.h: added enca_csname macro and #include <stdio.h> when
      DEBUG is defined

@heitbaum

Copy link
Copy Markdown
Contributor Author

Thank you for your contribution, makes sense. You can utilize DEBUG.

changelog entry

2003-06-24  David Necas (Yeti) <yeti@physics.muni.cz>
    * lib/internal.h: added enca_csname macro and #include <stdio.h> when
      DEBUG is defined

I don’t think this is the right logic. -DNDEBUG does not define -DDEBUG. They are completely separate and unrelated macros. -DNDEBUG defines the macro NDEBUG that disables assert() statements, in the C standard.

So the release build (which defines -DNDEBUG) would just treat the #ifdef as a noop. But when compiling without -DNDEBUG the assert would not activate (as it should along with the other asserts throughout the code.)

@Syed-Shahrukh-OSSRevival

Copy link
Copy Markdown
Member

Thank you @heitbaum for your help, you are correct!

Adding the missing part for completion.

Reproduce:

./configure  CFLAGS="-DNDEBUG"
gcc -DHAVE_CONFIG_H -I. -I..  -DEXTCONV_DIR=\"/usr/local/libexec/enca/extconv\"   -Wall -Wextra -W -pedantic -DNDEBUG -MT enca-convert.o -MD -MP -MF .deps/enca-convert.Tpo -c -o enca-convert.o `test -f 'convert.c' || echo './'`convert.c
convert.c: In function ‘xtable’:
convert.c:504:11: warning: variable ‘map_created’ set but not used [-Wunused-but-set-variable]
  504 |       int map_created;
      |           ^~~~~~~~~~~
convert.c:529:9: warning: variable ‘map_created’ set but not used [-Wunused-but-set-variable]
  529 |     int map_created;
      |         ^~~~~~~~~~~

merging the PR 👍

@Syed-Shahrukh-OSSRevival Syed-Shahrukh-OSSRevival merged commit b26a8a2 into Project-OSS-Revival:master Apr 28, 2026
3 checks passed
@heitbaum heitbaum deleted the patch-1 branch April 28, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants