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

flex.skl calls fileno(), which is not ISO C99 function #263

Closed
Explorer09 opened this issue Sep 4, 2017 · 4 comments
Closed

flex.skl calls fileno(), which is not ISO C99 function #263

Explorer09 opened this issue Sep 4, 2017 · 4 comments
Milestone

Comments

@Explorer09
Copy link
Contributor

I caught this warning when building flex in -std=c99 mode:

./stage1flex   -o stage1scan.c ./scan.l
  CC       flex-stage1scan.o
stage1scan.c: In function ‘yy_init_buffer’:
stage1scan.c:4757:48: warning: implicit declaration of function ‘fileno’; did you mean ‘mblen’? [-Wimplicit-function-declaration]
         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
                                                ^~~~~~
                                                mblen

In glibc, fileno() prototype is exposed only if _POSIX_C_SOURCE is defined to >= 1. Although flex will build with _GNU_SOURCE defined (AC_USE_SYSTEM_EXTENSIONS in configure script), the problem is that generated scanners may not build if the user's environment requires strict ISO C99, and I consider this a bug.

So this issue report is about two things:

  1. The #define _POSIX_C_SOURCE 1 is missing in flex.skl when the scanner is specified neither always-interactive or never-interactive option.
  2. We didn't document that we use POSIX functions to detect whether the input is "interactive", and so brings surprise to users that expect it builds in non-POSIX environments.
@westes
Copy link
Owner

westes commented Sep 4, 2017

What about rewriting to not use fileno() and being C99 compliant that way?

@westes
Copy link
Owner

westes commented Sep 4, 2017

I checked against my copy of the glibc reference manual and it doesn't note anything special about fileno() as well. Which is unfortunate given what you describe.

@westes westes modified the milestone: 2.6.5 Sep 4, 2017
@Explorer09
Copy link
Contributor Author

@westes
For your first question, it won't help much if we replace fileno() with something else since the routine already depends on isatty(), and so I'm pursuing only to have the feature macro defined.
For your second question, glibc manual doesn't explicitly mention about feature macro requirements, but Linux man pages does, as well as the code of "/usr/include/stdio.h" and "features.h":

/*stdio.h*/
#ifdef	__USE_POSIX
/* Return the system file descriptor for STREAM.  */
extern int fileno (FILE *__stream) __THROW __wur;
#endif /* Use POSIX.  */
/*features.h*/
#if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
# define __USE_POSIX	1
#endif

@westes
Copy link
Owner

westes commented Sep 4, 2017 via email

@westes westes removed this from the 2.6.5 milestone Oct 5, 2017
Explorer09 added a commit to Explorer09/flex that referenced this issue Oct 8, 2017
This fixes westes#263 where we lack feature macro to expose the API of
fileno().
Explorer09 added a commit to Explorer09/flex that referenced this issue Oct 13, 2017
This fixes westes#263 where we lack feature macro to expose the API of
fileno().
@westes westes added this to the 2.6.6 milestone Oct 31, 2017
@westes westes closed this as completed in a17d79e Nov 3, 2017
devreal added a commit to devreal/ompi that referenced this issue Jul 10, 2024
Flex prior to 2.6.6 uses fileno() but does not define the needed
feature test macros.
See westes/flex#263 for details.

Signed-off-by: Joseph Schuchart <joseph.schuchart@stonybrook.edu>
devreal added a commit to devreal/ompi that referenced this issue Jul 10, 2024
Flex prior to 2.6.6 uses fileno() but does not define the needed
feature test macros.
See westes/flex#263 for details.

Signed-off-by: Joseph Schuchart <joseph.schuchart@stonybrook.edu>
devreal added a commit to devreal/ompi that referenced this issue Jul 10, 2024
Flex prior to 2.6.6 uses fileno() but does not define the needed
feature test macros.
See westes/flex#263 for details.

Signed-off-by: Joseph Schuchart <joseph.schuchart@stonybrook.edu>
devreal added a commit to devreal/ompi that referenced this issue Jul 15, 2024
Flex prior to 2.6.6 uses fileno() but does not define the needed
feature test macros.
See westes/flex#263 for details.

Signed-off-by: Joseph Schuchart <joseph.schuchart@stonybrook.edu>
devreal added a commit to devreal/ompi that referenced this issue Jul 16, 2024
Flex prior to 2.6.6 uses fileno() but does not define the needed
feature test macros.
See westes/flex#263 for details.

Signed-off-by: Joseph Schuchart <joseph.schuchart@stonybrook.edu>
devreal added a commit to devreal/ompi that referenced this issue Sep 10, 2024
Flex prior to 2.6.6 uses fileno() but does not define the needed
feature test macros.
See westes/flex#263 for details.

Signed-off-by: Joseph Schuchart <joseph.schuchart@stonybrook.edu>
wenduwan pushed a commit to devreal/ompi that referenced this issue Sep 10, 2024
Flex prior to 2.6.6 uses fileno() but does not define the needed
feature test macros.
See westes/flex#263 for details.

Signed-off-by: Joseph Schuchart <joseph.schuchart@stonybrook.edu>
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

2 participants