• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Mixing Objective C and C++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mixing Objective C and C++


  • Subject: Re: Mixing Objective C and C++
  • From: "chinmoy Gavini" <email@hidden>
  • Date: Sat, 31 Mar 2007 00:26:59 -0500



>>What's the difference between code compiled in Objective C as
opposed to Objective C++?

So, I have  a  objective-C++ project setup(not related to Quark) where my application logic is in Cocoa(Objective-C part) and the application logic is in C++(the application logic also depends on several C++ libraries). Looking at the build log, code written purely in Objective C does not need g++(the C++ compiler) in order to compile.
In an Objective-C++ project, where one mixes C++ code with Objective-C code inside file suffixed with .mm, the Xcode build system uses calls to both g++ and gcc(the C and Objective-C compiler).



>> Strangely though it seems to be able to load Objective C XTensions (you just can't call any library functions)

My guess is that you can't call any library functions because they are in C++(they are in C++, right?). The build system is  probably not linking in the C++ libraries when you only use the Objective-C compiler . The Objective-C part would work fine, but there was no linking of the C++ libraries, so you can't use the library functions.From what I have seen in my project, linking external C++ libraries is done only with g++. By the way, could you elaborate on what you mean by "compiled (only) with the Objective C compiler" -- do you mean keeping the .m files and not changing their extensions to .mm?


>> - What is it about the Objective C++ compiler that renders an
XTension unloadible while the Objective C compiled version can at
least load?

Just a thought: do you have the -bind_at_load (hyphen followed by bind_at_load) option added to your Objective-C++ project settings' Other Linker Flags? (if not, see if adding that makes any difference--the bind_at_load would affect the linking part of the build process). Just a sanity check - make sure Zerolink is disabled in the project settings(you probably did this already).

On 3/30/07, Ken Tozier <email@hidden> wrote:
After spending the afternoon playing around with this, I found out
the following:

- If the project is compiled with the Objective C compiler, Quark
loads my XTension (as evidenced by NSLogs in some of the methods) but
any calls to Quark library functions from inside a method crashes the
app. This seems to make sense as the Quark headers are bristling with
conditionals like the following

#if defined(__cplusplus) || defined(inline)
        /* inline functions here */
#else
        /* macros here */
#endif

- If the Objective C++ compiler is used, it compiles without error.
When you go to run it, however, Quark has some sort of internal
checker and pops up a dialog stating that the XTension isn't
compatible with the current version.


Which leads to the following questions:

- What's the difference between code compiled in Objective C as
opposed to Objective C++? I understand they are different languages
but if anything, I would have thought that the Objective C compiled
version would have less of a chance of loading than the Objective C+
+, as Quark XTensions require a C++ compiler. Strangely though it
seems to be able to load Objective C XTensions (you just can't call
any library functions)

- What is it about the Objective C++ compiler that renders an
XTension unloadible while the Objective C compiled version can at
least load?

- After reading Apple's info on Objective C++, I understand that
there are some differences between it and straight C++, but since I
have no access to the inner workings of the Quark library, what it's
doing under the hood can only be guessed. What kinds of differences
are there between Objective C++ and straight C++ that could prevent
loading of a library?

Thanks for any insight/help

Ken


On Mar 30, 2007, at 2:23 PM, Ken Tozier wrote:

> Hi
>
> I'm working on a Quark XTension which requires that code be
> compiled with a C++ compiler. I've been hacking around in copies of
> the headers with the goal of getting the project to compile in
> Objective C. I finally got it working but when Quark loads the
> XTension it crashes. The crash log tries to run but hangs with an
> infinite spinning beach ball.
>
> Next I tried compiling with the Objective C++ compiler and got the
> following error:
>
> /usr/bin/ld: multiple definitions of symbol __Z8IsBitSetPPym.eh
>
> I'm not really knowledgeable enough about the nitty gritty compiler
> details to know whether it's even possible to do what I'm trying to
> do. I have no control over the Quark stuff beyond the ability to
> group items within conditionals in the header. Is there some trick
> I can use so that the Objective C or Objective C++ compiler will
> create calls to Quark functions as if the C++ compiler was used?
>
> Thanks for any help
>
> Ken
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription: email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (

This email sent to email@hidden



--
Chinmoy Gavini
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Mixing Objective C and C++
      • From: Ken Tozier <email@hidden>
References: 
 >Mixing Objective C and C++ (From: Ken Tozier <email@hidden>)
 >Re: Mixing Objective C and C++ (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: Build slowdown with 4 processors vs. 2 or 1?
  • Next by Date: Re: Mixing Objective C and C++
  • Previous by thread: Re: Mixing Objective C and C++
  • Next by thread: Re: Mixing Objective C and C++
  • Index(es):
    • Date
    • Thread