Mail Archives: cygwin/2008/06/04/20:37:46
Hi,
Recently, I updated my cygwin flex from 2.5.4 to 2.5.35-1 and my build has been breaking because of changes in flex.skl.
Specifically, I have a problem with extern declaration of isatty in flex.skl. In 2.5.35-1, it is done like this in flex.skl:
%if-c-only
m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]],,
[[
m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]],,
[[
#ifdef __cplusplus
extern int isatty M4_YY_PARAMS( int );
#endif /* __cplusplus */
]])
]])
%endif
The problem is that I've been long using flex to generate a C skeleton and then compiling it with a C++ compiler. Thus the extern declaration in the generated lexer is #if'ed out since __cplusplus is defined. One might say, well, just don't do that. But AFAICT, this is a sanctioned usage of flex. The flex manual states that it should be possible:
"flex provides two different ways to generate scanners for use with C++. The first way is to simply compile a scanner generated by flex using a C++ compiler instead of a C compiler." [1]
My proposal is to replace:
#ifdef __cplusplus
extern int isatty M4_YY_PARAMS( int );
#endif /* __cplusplus */
with a more C/C++ portable construct:
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
extern int isatty M4_YY_PARAMS( int );
#ifdef __cplusplus
}
#endif /* __cplusplus */
This solves the problem by allowing both C and C++ compilers to work with generated lex.yy.c files.
Thanks,
dante
1. http://www.gnu.org/software/flex/manual/html_chapter/flex_19.html#SEC19
__________________________________________________________________
Connect with friends from any web browser - no download required. Try the new Yahoo! Canada Messenger for the Web BETA at http://ca.messenger.yahoo.com/webmessengerpromo.php
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -