Ticket UUID: | 941042 | |||
Title: | Remove TCL_STORAGE_CLASS monkey business | |||
Type: | Patch | Version: | None | |
Submitter: | jenglish | Created on: | 2004-04-23 22:52:35 | |
Subsystem: | 70. Sample Extension | Assigned To: | hobbs | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2010-09-30 02:23:04 | |
Resolution: | Wont Fix | Closed By: | sf-robot | |
Closed on: | 2010-09-29 19:23:04 | |||
Description: |
The attached patch replaces the (confusing, and incorrect) preprocessor gyrations: #ifdef BUILD_sample #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT #endif with the usual Windows idiom, defining a distinct SAMPLE_STORAGE_CLASS macro instead of hijacking Tcl's EXTERN macro. | |||
User Comments: |
sf-robot added on 2010-09-30 02:23:04:
This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker). hobbs added on 2010-08-14 03:27:59: See also 2025889. We do need to separate the BUILD_$pkg variants in case one TEA extension depends on another (includes it's .h), which also means we'd need the $pkg_STORAGE_CLASS. The problem I have with this proposal is that it requires changes on several lines, rather than the single BUILD_$pkg in a .h file that is currently needed. Can someone convince me this is a better approach? nobody added on 2005-02-02 09:54:32: Logged In: NO The usual convention on Windows is to define a preprocessor symbol like "XXXAPI", and use declarations like "extern XXXAPI XXX_Foo(void);", where XXXAPI expands to "__declspec(dllexport)" in source modules that are part of the library and "__declspec(dllimport)" in source modules that use the library. This is basically how <tcl.h> defines the EXTERN macro (which probably should have been called "TCLAPI" instead of "EXTERN", but that's an historical accident.) The preprocessor gyrations that Tk and the sampleextension go through aren't necessarily incorrect, but they are confusing, error-prone, and unnecessarily complicated. The #ifdef / #undef / #define / #include / #undef / #define cycle is basically hijacking Tcl's storage class macro "EXTERN" and temporarily repurposing it to mean "My package's public symbols" instead of "Tcl's public symbols". The conventional idiom would be for each extension to define its own storage class macro instead; that's what the patch does. Also, for simple extensions that are only dynamically loaded and don't export a public, non-stubbed API to dependent extensions, you don't even need to do that: just declare the _Init() routine as DLLEXPORT and it will do the right thing on all platforms. hobbs added on 2005-02-02 07:43:25: Logged In: YES user_id=72656 What is incorrect about the current incantations? jenglish added on 2004-04-24 05:52:35: File Added - 84863: sampleextension-monkey-business.patch |
Attachments:
- sampleextension-monkey-business.patch [download] added by jenglish on 2004-04-24 05:52:35. [details]