discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: patch for compatible syntax with C++


From: Andrew Pinski
Subject: Re: patch for compatible syntax with C++
Date: Tue, 27 Jul 2004 00:32:20 -0700


On Jul 27, 2004, at 12:18 AM, Cristobal Castillo wrote:

I am working with Objectice-C and C++, and also working with non-gnu compilers.

Now if you read the license of libobjc, you cannot use libobjc legally with a non-GCC
unless your software becomes GPL.

I have a problem with libobjc library, since it does not have compatible syntax with C++. Problems found and solved are listed below, a patch is proposed to consider merging it
with current source code base.

1) Class is a keyword in C++, but it is used as variable name in several places. I think these
changes have been done already for Objective-C++ GCC frontend.
Example:

- Method_t class_get_instance_method(Class class, SEL aSel);
+ Method_t class_get_instance_method(Class CLASS, SEL aSel);

This has not changed already on the mainline but is done differently
on the objc-improvements-branch so this will change.


2) Void pointer arithmetic does not work with some compilers (it has been substituted by
char pointer arithmetic). Example:

hash_string (cache_ptr cache, const void *key)
while (*(char *) key) {
  ret^= *(char *) key++ << ctr;
  ctr = (ctr + 1) % sizeof (void *);
}

Since this is a GCC extension this is not going to change at least not yet, sorry.
Old saying, if it is not broken don't fix it.

I am also not a fan of extraneous casts like:
+    return ! strcmp ((char*)k1, (char*)k2);
which in my mind a bug in C++ (and was one in K&R C).

Andrew Pinski
libobjc maintainer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]