Tcl Source Code

View Ticket
Login
Ticket UUID: 633990
Title: tcl.h always makes incorrect #define
Type: Bug Version: obsolete: 8.4.1
Submitter: edwardross Created on: 2002-11-05 19:27:37
Subsystem: 40. Dynamic Loading Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-06-13 02:46:24
Resolution: Out of Date Closed By: hobbs
    Closed on: 2007-06-12 19:46:24
Description:
PROBLEM
---------------

in tcl.h TCL_STORAGE_CLASS is correctly defined arround
line 249 with the following:

#undef TCL_STORAGE_CLASS
#ifdef BUILD_tcl
# define TCL_STORAGE_CLASS DLLEXPORT
#else
# ifdef USE_TCL_STUBS
#  define TCL_STORAGE_CLASS
# else
#  define TCL_STORAGE_CLASS DLLIMPORT
# endif
#endif

However later in the same file arround line 1691, it is
incorrectly defined as:

#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS

EXTERN intTcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp));

#endif /* RESOURCE_INCLUDED */

#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT

This usually doesn't cause any problems, but if you
then try to link with proWrap.h, this incorrect
definition of TCL_STORAGE_CLASS means that we can't
link.  Would also be a problem for linking with static
libs rather than dlls  (obviously talking about on
windows here).

Workaround
------------------

Undefine TCL_STORAGE_CLASS before include proWrap.h.

Possible Resolution
-----------------------------

(1) change the definition at line 249 to:

#ifdef __cplusplus
#  define HEAD_EXTERN extern "C"
#else
#  define EXTERN extern TCL_STORAGE_CLASS
#endif

#define EXTERN HEAD_EXTERN TCL_STORAGE_CLASS

(2) Remove all further defines/undefines for
TCL_STORAGE_CLASS at line 1694 etc.

(3) change the declaration at line 1694 to:
EXTERN_HEAD int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp
*interp));
User Comments: edwardross added on 2003-07-19 03:00:31:
Logged In: YES 
user_id=578816

Looks like I made a mistake in my suggested resolution. 
Perhaps I meant:

Possible Resolution
-----------------------------

(1) ADD the following definition after the definition of
TCL_STORAGE CLASS:

#ifdef __cplusplus
# define HEAD_EXTERN extern "C"
#else
# define HEAD_EXTERN extern
#endif

#define EXTERN HEAD_EXTERN TCL_STORAGE_CLASS

(2) Remove all further defines/undefines for
TCL_STORAGE_CLASS at line 1694 etc.

(3) change the declaration at line 1694 to:
HEAD_EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp
*interp));

davygrvy added on 2003-07-19 02:59:20:
Logged In: YES 
user_id=7549

Please see tip#60, I have nothing to say on this specific 
problem except that it is covered there.

nobody added on 2003-02-17 03:13:38:
Logged In: NO 

It is possible that I did something wrong.  However, it is
clear that the header file is incorrect.

What could be a valid reason for undefing TCL_STORAGE_CLASS
and then redefining it as DLLIMPORT?

It is obvious from the initial definition (arround
line 249) that there are three possible correct values.

The undefining of the TCL_STORAGE_CLASS is a complete hack.
 It is simply incorrect!

kennykb added on 2003-02-17 02:50:53:
Logged In: YES 
user_id=99768

Jeff, what's the proper TEA2 thing to do here? I know that others
build extensions quite successfully even with TclPro headers.
I'm thinking that this is either the original submitter doing something
wrong, or else something amiss in <prowrap.h>.

davygrvy added on 2002-12-11 05:36:35:
Logged In: YES 
user_id=7549

See TIP #60

IMO, storage class is a big mess in Tcl.

edwardross added on 2002-11-06 02:27:38:

File Added - 34689: tcl.h

Attachments: