melling@cs.psu.edu (Michael D Mellinger) (01/26/91)
NeXT uses the C++ reserved word 'new' in stdio.h!!!!! I can't believe NeXT didn't catch this!!! Arrggh. I guess no one at NeXT actually uses C++. The simple fix: extern int rename(const char *old, const char *_new); -Mike
tenny@ootool.dec.com (Dave Tenny) (01/28/91)
In article <u-1Gbp*6@cs.psu.edu>, melling@cs.psu.edu (Michael D Mellinger) writes... > >NeXT uses the C++ reserved word 'new' in stdio.h!!!!! I can't believe >NeXT didn't catch this!!! Arrggh. I guess no one at NeXT actually >uses C++. > Look at it this way, at least you didn't pay money for G++. Some commercial ports of CFRONT (which shall remain nameless) don't even bother to integrate with the unix /usr/include files at all, rendering a half-assed library at best. And they charge lots of money. I'd like C++ too for my NeXT. But I'm not holding my breath for it. Even when I get 2.0, I know that G++ 1.37.1 has lots of bugs, and I've heard that the NeXT 2.0 release is an older version of G++. Further, I tried to build G++ 1.37.1, after building GCC 1.37.1. Unfortunately, GCC didn't understand the #import directive rampant in the /usr/include/* files. (Generally only included if you #include <sys/xxx> for some of the machine dependent stuff). I decided it wasn't worth the effort. So for my application, I've adopted the "When in Rome..." motto, and use Objective C. While it's syntactically uglier, doesn't offer the protection, implicit conversion, and ctor/dtor features I like about C++; it does at least support metaclass (for a lack of a better term, CLOS users please pardon the misuse) data, and some of those convenient conversions to and from ID which C++ doesn't allow. Finally, when you decide you hate ObjC and miss C++, remember that Interface Builder wouldn't have been nearly as nice in C++, unless they went to a fair amount of work do support the class operations which allow IB to function so well. waxing philosophic while I wait for my damn upgrade... Dave
sng@steveng.lotus.com (Stephen Ng) (01/29/91)
In article <u-1Gbp*6@cs.psu.edu> melling@cs.psu.edu (Michael D Mellinger) writes: NeXT uses the C++ reserved word 'new' in stdio.h!!!!! I can't believe NeXT didn't catch this!!! Arrggh. I guess no one at NeXT actually uses C++. The simple fix: extern int rename(const char *old, const char *_new); Actually, NeXT did a fair amount of testing on C++, and I know of one beta tester who developed a large commercial application in C++. To use the include files, you must put the following in your source code: extern "C" { #include <stdio.h> } This turns off C++ keywords while the file stdio.h is being processed. It also tells the compiler to use C linkage for the library functions in stdio.h.
erickson@frith.egr.msu.edu (Carl Erickson) (01/29/91)
In article <u-1Gbp*6@cs.psu.edu> melling@cs.psu.edu (Michael D Mellinger) writes: > > >NeXT uses the C++ reserved word 'new' in stdio.h!!!!! I can't believe >NeXT didn't catch this!!! Arrggh. I guess no one at NeXT actually >uses C++. > >The simple fix: > >extern int rename(const char *old, const char *_new); > > > >-Mike I got some help from NeXT on this problem. All you need to do is extern "C" { #include <stdio.h> } and you tell the C++ compiler that you will be using include files for ANSI C. This solves the sort of problem you had with re-use of the keyword "new". Carl -- erickson@egr.msu.edu || uunet!frith!erickson || erickson@msuegr.bitnet
glang@Autodesk.COM (Gary Lang) (02/01/91)
>>NeXT uses the C++ reserved word 'new' in stdio.h!!!!! I can't believe >>NeXT didn't catch this!!! Arrggh. I guess no one at NeXT actually >>uses C++. >I'd like C++ too for my NeXT. But I'm not holding my breath for it. >Even when I get 2.0, I know that G++ 1.37.1 has lots of bugs, and I've This is not a problem with NeXT's stdio.h. This is your problem. This happens with any mixed language environment. In fact there's a provision for it that's supported with the cc++ compiler. Just declare the language that a piece of code uses to the compiler. For example, in your case... extern "C" { #import <stdio.h> } Works like a champ. Similarly for objc headers... extern "Objective-C" { #import <appkit/Window.h> } One thing I found out that annoyed me was that id is not declared the same type as Object *...so if you have code like any good programmer should that looks like: self = [ Foo new ]; if ( self == nil ) errorDoSomething(); It will complain because self and nil aren't the same type (class) either directly nor transitively in the class hierarchy. id is a typedef of ther struct objc_object, which has the same structure as the Object class definition, but isn't defined as the latter, and so cc++ complains... Since I code for portability, I never directly include <objc/*.h> because I'd never place StepStone's headers in such a place; /usr/include belongs to my compiler on other platforms, and upgrading the compiler runs the risk of overwriting any clones of the NeXT directory structure I could come up with. So instead I have a local header I call objc.cf which, depending on which compiler/platform I'm on includes the correct objc.h. It also includes the Object category I defined to emulate the missing StepStone Object interface. So all I had to do was under nil and define it correctly. Good luck. -g -- Gary T. Lang (415)332-2344 x2702 Autodesk, Inc. Sausalito, CA. MCI: 370-0730