delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/06/04/20:37:46

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
X-Mailer: YahooMailWebService/0.7.199
Date: Wed, 4 Jun 2008 17:37:09 -0700 (PDT)
From: Dante Allegria <danteallegria AT yahoo DOT ca>
Reply-To: danteallegria AT yahoo DOT ca
Subject: flex 2.5.35-1: isatty() problem (and solution)
To: cygwin AT cygwin DOT com
MIME-Version: 1.0
Message-ID: <100308.36291.qm@web52812.mail.re2.yahoo.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019