• 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: Building a C library Objective-C wrapper framework
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Building a C library Objective-C wrapper framework


  • Subject: Re: Building a C library Objective-C wrapper framework
  • From: Brian Stern <email@hidden>
  • Date: Tue, 15 Jul 2008 11:38:35 -0400


On Jul 15, 2008, at 8:12 AM, Sebastian wrote:

-------------- Original message ----------------------
From: Sebastian Nowicki <email@hidden>
> I also can't think of a way to use the typedef'd C structs and
> enums from the library in the header file without including the
> library header file. This is tricky indeed. If only I could see how
> Apple did it with OpenGL, etc :P.
There are very few places where I actually return an enum from the C library. As previously mentioned, I simple don't know how to handle this, and it would be returning an enum either way (I'd just need an "alias"). I mostly use the structs from the library internally, ie., as instance variables. It would otherwise be impossible for me to do anything in the class :P. For instance if there's a struct apple_t, I make a class Apple, and internally the class must store the apple_t struct somewhere. In order to define this variable I have to import the header from the library. e.g:

struct*s are easy.

struct apple_t *apple;

will compile without a definition of apple_t available to the compiler. You need to #include the definition in order to use it though. This strategy is used in Apple's headers to hide private info. See OpaqueAudioFileID for instance.

For the enums you could make your own that have the same values as the one from the C library.

enum { mySome_enum = whatever some_enum is from the library }

Obviously you need to be very certain that all of your new enums have the same values as the library values.




-- Brian Stern email@hidden



_______________________________________________
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


References: 
 >Re: Building a C library Objective-C wrapper framework (From: email@hidden)
 >Re: Building a C library Objective-C wrapper framework (From: Sebastian <email@hidden>)

  • Prev by Date: Re: Xcode project has lost track of file modification
  • Next by Date: Download Sizes
  • Previous by thread: Re: Building a C library Objective-C wrapper framework
  • Next by thread: getting files of current directory
  • Index(es):
    • Date
    • Thread