Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignoring return value of 'freopen': all warnings being treated as errors #14

Closed
ecerulm opened this issue Dec 11, 2014 · 1 comment
Closed

Comments

@ecerulm
Copy link
Contributor

ecerulm commented Dec 11, 2014

Hi,

I tried to compile in the current HEAD on Ubuntu 14.04 and Im getting

make  all-recursive
make[1]: Entering directory `/home/ecerulm/tmp/pick'
Making all in src
make[2]: Entering directory `/home/ecerulm/tmp/pick/src'
gcc -DHAVE_CONFIG_H -I. -I..    -Wall -Wextra -pedantic-errors -Wno-unused-parameter -Werror -g -O2 -MT ui.o -MD -MP -MF .deps/ui.Tpo -c -o ui.o ui.c
ui.c: In function ‘start_curses’:
ui.c:48:9: error: ignoring return value of ‘freopen’, declared with attribute warn_unused_result [-Werror=unused-result]
  freopen("/dev/tty", "r", stdin);
         ^
cc1: all warnings being treated as errors
make[2]: *** [ui.o] Error 1
make[2]: Leaving directory `/home/ecerulm/tmp/pick/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ecerulm/tmp/pick'
make: *** [all] Error 2

I guess that the freopen call should be wrapped in an assert()

@ecerulm
Copy link
Contributor Author

ecerulm commented Dec 13, 2014

I created pull request #16 which solves this issue and #15.

The source of the problem is that freopen in Ubuntu 14.04 is defined with __attribute__((warn_unused_result)) so it will generate a warning (I guess that in other platforms it's lacking this attribute). Since warnings are treated as errors , ignoring the return value of freopen breaks the build. #16 asserts the the return value is non-null.

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

No branches or pull requests

1 participant