From: <no...@so...> - 2002-06-05 23:33:18
|
Feature Requests item #565088, was opened at 2002-06-05 16:33 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=360894&aid=565088&group_id=10894 Category: 48. Portability Support Group: None Status: Open Resolution: None Priority: 3 Submitted By: Joe English (jenglish) Assigned to: Joe English (jenglish) Summary: Bring tcl.h into the 1990s Initial Comment: Brief summary: <tcl.h> contains several preprocessor macros intended to aid source-level compatibility between ANSI C and K&R C compilers. However, the #ifdef logic tends to assume K&R C by default and enables modern features based on the presence of __STDC__ and/or other special cases. Since pre-ANSI compilers are a rarity nowadays (2002), and many compilers do not define __STDC__ in the default (non-strict-ansi) mode even though they do in fact support all the relevant features, it would make more sense to assume modern C by default and only enable the backwards-compatibility macros on a special-case basis. I'll put together a patch in the next couple of days. Detailed analysis (from a post to comp.lang.tcl): From: jen...@fl... (Joe English) Newsgroups: comp.lang.tcl Subject: Re: Build problem using aCC on HP-UX Date: 5 Jun 2002 15:32:02 GMT Message-ID: <adl...@en...> [...] The Tcl core was C89-compatible until the recent (8.4a2? 3?) addition of "long long", which is a C99 feature. (Actually, I'm not sure under which conditions 'long long' is actually used -- it's tough to decipher what's going on in the #ifdef chain in tcl.h). However, the core also includes backwards-compatibility #defines for several features which were not present in K&R C (VOID, CONST, USE_PROTOTYPE, USE_STDARG, etc.). The choice of whether to use C89 or K&R features is determined by whether or not __STDC__ is #define'd, or, in many cases, with an additional list of special cases, e.g. # if defined(__STDC__) || defined(__cplusplus) || defined(__BORLANDC__) Most compilers nowadays (in my experience) are C89, but do not yet fully support C99. Many of these support C9X features like "long long", but only when invoked in "extensions-enabled" mode. Here's where the problem comes up: "long long" is standard C99, but it's an extension to C89; thus 20th century compilers don't enable it in "strict ANSI" mode and Tcl 8.4 can't be compiled in that mode. Most compilers -- GCC being a notable exception -- don't define __STDC__ when extensions are enabled, so all of the backwards-compatibility cruft in tcl.h gets activated (except on platforms which have been accounted for by a special-case preprocessor test as above). The correct way to proceed is IMO to bring tcl.h into the 1990s: it should assume C89 features are present by default (void, const, stdarg.h, etc.), and only enable the backwards-compatibility cruft on a special-case basis, instead of the other way around. For example, instead of: #if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) \ || defined(__cplusplus) || defined(USE_PROTOTYPE) # define _USING_PROTOTYPES_ 1 # define _ANSI_ARGS_(x) x # define CONST const #else # define _ANSI_ARGS_(x) () # define CONST #endif use something like: #if defined(ANCIENT_COMPILER) # define CONST # define _ANSI_ARGS_(x) #else # define _ANSI_ARGS_(x) x # define CONST const #endif where ANCIENT_COMPILER is undefined by default. ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=360894&aid=565088&group_id=10894 |