Re: <types.h> and other includes
Re: <types.h> and other includes
- Subject: Re: <types.h> and other includes
- From: David Leimbach <email@hidden>
- Date: Tue, 22 Feb 2005 20:57:48 -0800
On Tue, 22 Feb 2005 18:21:41 -0700, Markian Hlynka
<email@hidden> wrote:
>
>
> Ok, so, I have a project that compiles fine in xcode. I usually have
> this project compiling under various unices as well. Today, I tested
> the linux compile. I should add that I _also make sure this stuff
> compiles on the MacOS command line using make. So, once I'd changed
> Makefile to makefile, and other silliness, two things bothered me after
> moving to linux:
>
> Starting with the lesser...
>
> 1. I had to add #include <stdlib.h> to a file when using the makefile,
> because it didn't know what exit() was. Why didn't xcode have a problem
> with this? If xcode has a bunch of automatic includes, is it feasible
> to disable them so I get the same errors for inclusion as I would when
> running make? And, if this was an xcode thing, why didn't gcc/make on
> OS X have trouble with this?
>
Not sure what functions you called but in C all functions without prototypes are
assumed to exist and return "int".
So if you just call printf without using stdio.h you'll probably get
something the linker
can reasonably deal with.
> 2. I used a type, u_int16_t. Neither xcode nor gcc/make on OS X
> required me to do anything. however, on linux I had to #include
> <sys/types.h> Why?
>
Not sure why u_int16_t would be defined by default... Some automatic
Framework includes perhaps?
> More annoyingly, I wanted to make sure that if I had included
> <sys/types.h> in the mac code, it would still work. Well, first I went
> to xcode and command-clicked u_int16_t so see the definition. It too me
> to /usr/include/ppc/types.h. Upon routing around I ALSO discovered
> types.h files in /usr/include/sys/ and /usr/include/machine/
>
Yep. I bet on Linux if you look at sys/types.h you'll see that it includes some
other file too.. .that file may include another. Xcode is finding
exactly where that
definition is... not some middle header that includes it by including
another header.
> I'm not sure if I diffed every combination, but they are NOT all the
> same. What's going on here? by included sys/types.h have I overridden
> the /ppc/types.h? added to it?
>
> And, more importantly, again, what's the deal? I want my OS X compiles,
> whether with xcode or makefile, to require me to include the same
> things as much as possible as linux will. I realize that for some
> things this isn't going to be possible. However, I'm writing pretty
> straight-up un-fancy code here.
Your build setting should be set to higher warning levels most likely
so that the
compiler doesn't take it so easy on you. You might even want to try
"-pedantic" and
"-Wall" and "-Werror". That's how I build my code and it's beaten me
about the head and
neck enough to know what not to do :).
Dave
_______________________________________________
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