This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: patch for compatible syntax with C++



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]