• 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: Carbon with UNIX
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Carbon with UNIX


  • Subject: Re: Carbon with UNIX
  • From: Ian Krieg <email@hidden>
  • Date: Sun, 16 Jan 2005 16:31:14 -0500

Title: Re: Carbon with UNIX
> If the code is compiled as C++, then structs can be referenced
> without the keyword "struct".  If it's compiled as C, you will need
> the keyword "struct".  This is standard, and not Mac-specific.
>
> Ian Krieg

As I was thinking about it after I sent the email, I thought of this
explanation as well. However, the file is a .cpp file so shouldn't Xcode
compile it as C++? Or is there some option buried somewhere that allows
me to chose? Or perhaps there is something smarter going on internally
that knows that what I've written is actually C code in a .cpp file.
Edwin V

Apparently this is not exactly the reason.  I made a test file and had the same problem you did.  When I defined a struct of my own in the file, it could be used fine without the struct keyword.  I thought perhaps it was something about how the API headers were treated after being included, so I found an arbitrary struct in another header, "_pthread_handler_rec", but it worked fine without the keyword "struct".

The following compiles as a C++ Console Tool, but does not if I remove the "struct" keyword from in front of the declaration of sb.


#include <sys/types.h>
#include <sys/stat.h>
#include <iostream>

struct hilo
{
   
int v;
};

int main (int argc, char * const argv[]) {
    std::cout <<
"Test" << std::endl;
   
struct stat sb;
    stat(
"/tmp", &sb);
   
    std::cout <<
"Test" << std::endl;
    hilo loop = {
20};
    std::cout << loop.v << std::endl;
   
    _pthread_handler_rec rec;
   
    return 0;
}

Do any of the Apple guys on this list know what might cause this?  If no one can explain this, you should probably file a bug report, Edwin.

Ian Krieg
 _______________________________________________
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: Carbon with UNIX
      • From: Alexey Proskuryakov <email@hidden>
    • Re: Carbon with UNIX
      • From: Shawn Erickson <email@hidden>
References: 
 >Carbon with UNIX (From: Edwin Vane <email@hidden>)
 >Re: Carbon with UNIX (From: Markus Hitter <email@hidden>)
 >Re: Carbon with UNIX (From: Edwin Vane <email@hidden>)
 >Re: Carbon with UNIX (From: Ian Krieg <email@hidden>)
 >Re: Carbon with UNIX (From: Edwin Vane <email@hidden>)

  • Prev by Date: Re: Carbon with UNIX
  • Next by Date: Re: Carbon with UNIX
  • Previous by thread: Re: Carbon with UNIX
  • Next by thread: Re: Carbon with UNIX
  • Index(es):
    • Date
    • Thread