[comp.sys.amiga.programmer] C++ access of AmigaDOS C routines

comeau@ditka.Chicago.COM (Greg Comeau) (05/23/91)

In article <72373@microsoft.UUCP> davidbro@microsoft.UUCP (Dave BROWN) writes:
>In article <38576@ditka.Chicago.COM> comeau@csanta.attmail.com (Greg Comeau) writes:
>>I'm not versed enough in AmigaDOS specific, however what I can tell you
>>is that compiler supporting either the 2.0 or 2.1 spec of C++ have
>>something called 'extern "C"' syntax which allows you an interface to
>>C.  Under some, for instance, Comeau C++, we literally pick up your C
>>compilers include files.  Hence, the call in C++ would be *EXACTLY* the
>>same as it would be in C.
>
>Just to pick nits, this is true unless the AmigaDOS or Intuition function
>name is the same name as a method in a current class definition, in which case
>the name would be prepended with :: .

I was not referring to doing anything special with the functions like putting
then into a class.  I was just mentioning that the current facilities of
accessing C routines, be it printf or any other(s), is not a problem.

In any event, to make it clear to the net what Dave is referring to, it is
something like this:

class someclass {
    /* ... */
    int printf(const char *, ...);
    /* ... */
    void someotherfunc() {
	printf("Hello, world\n"); // This calls someclass's printf
	::printf("Hello, world\n"); // This calls the C file scoped printf
        // The :: is not required outside of someclass's ``member functions''
        // since there would only be on printf outside the class and if
        // someclass's printf was needed it would be used via normal class
        // instance syntax: someclass asomeclass; asomeclass.printf();
    }
};

-- Greg
-- 
	 Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418
                          Producers of Comeau C++ 2.1
          Here:attmail.com!csanta!comeau / BIX:comeau / CIS:72331,3421
                     Voice:718-945-0009 / Fax:718-441-2310