Skip to content
Tcl Source Code View Ticket
Login

View Ticket

tclOOInt.h Class type conflicts with Objective C

Closed / Fixed2163447fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-10-13 11:55:08
Class is a reserved type in Objective C, its use by tclOOInt.h makes it impossible to include that file in any objc code or to compile the core with an objc compiler, due to errors like:

tcl/generic/tclOOInt.h:255: error: conflicting types for 'Class'
<built-in>:0: error: previous declaration of 'Class' was here 

the patch below works around the issue, it would probably be even better to globally rename the unadorned TclOO types Class and Object to TclClass and TclObject

diff --git c/tcl/generic/tclOOInt.h w/tcl/generic/tclOOInt.h
index 56edcc4..8b4b107 100644
--- c/tcl/generic/tclOOInt.h
+++ w/tcl/generic/tclOOInt.h
@@ -15,6 +15,8 @@
 #include <tclInt.h>
 #include "tclOO.h"
 
+#define Class TclClass
+
 /*
  * Forward declarations.
  */
dkfplain2008-10-13 20:34:16
Assuming that __OBJC__ is the #def to look for to detect Objective C (which it seems to be from both the OSX headers and a grep online) it's now fixed.
dkf Closed ticket [2163447fff]. [History diff]2008-10-13 20:34:17
dasplain2008-10-13 21:57:42
Hi Donal,
__OBJC__ is correct, thanks.
Is there a reason not do the defines unconditionally?
I'm concerned that there will be issues if some source files in a project are compiled with objc and others not (as will certainly be the case in Tk when we start using Cocoa APIs)
dkfplain2008-10-13 22:04:20
The only files that use Class/Object are files that include tclOOInt.h, as nothing else declares those types — I'm kind-of careful about such things! — so the fix that's there should be adequate. If someone's poking their nose inside improperly and gets burned, we don't care (or we're in the core and can fix things pretty easily by including the correct header).
dasplain2008-10-13 22:22:16
ight, good, no problem then, thanks (I somehow thought tclOOInt.h resp. tclOOIntDecls.h was included by tclInt.h, but I now see that is not the case, so there is no issue)
The only reason I noticed this BTW is that I am building the whole of tcl & tk statically with 'gcc -x objective-c' for development...
Log in (anonymous is fine) to add a comment.