Re: Carbon with UNIX
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