Unix Programming - Slightly confused - header problem.

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2004 > Slightly confused - header problem.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Slightly confused - header problem.
M. B. Trausch

2004-11-19, 5:51 pm

I'm going through a book at the moment, and keying the examples in, one
at a time, and so forth, and I'm having trouble with one of them.
First, let me show you the include section:

-----------
#include <fnctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-----------

Now, this is obviously at the top of the file, and right from the
get-go, I have an error (on *every* Linux box that I've tried building
it on) stating that fnctl.h doesn't exist, specifically:

arglist.c:5:19: fnctl.h: No such file or directory

Which, leads to another error in the source:

arglist.c:30: `O_RDONLY' undeclared (first use in this function)

Now, from what I've found on Google, this is/was something part of the C
library, which makes sense, because the book doesn't call for any
additional libraries.

So, why is it that if the C library developer package is installed, and
this book is a Linux programming book, and the rest of the header files
are there, that no Linux system that I've found to try this on yet, will
build it?

Also, I got the same thing on a NetBSD system.

Was there a change to the C library, or something?

MT
Alex Fraser

2004-11-19, 5:51 pm

"M. B. Trausch" <fd0man@gmail.com> wrote in message
news:1100883984.KPSTx7lX9BpyNcKhiBwwvg@teranews...
[snip]
> arglist.c:5:19: fnctl.h: No such file or directory


That'll be because it should be <fcntl.h>.

HTH,
Alex


M. B. Trausch

2004-11-19, 5:51 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alex Fraser wrote:
|
| That'll be because it should be <fcntl.h>.
|

Ha! Thanks!

I just double-checked, and it's most certainly a typo in the original
listing. Whoops.

*shrugs*

Thanks, again! :-P
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBnkOHcNB5yDSBR3oRAgT6AJ9jk/hbUOm4kNQyxHiE06Lx4G3eKwCcDoFe
GyWHT8RXGSoVwCqA4Nqq2I0=
=XLT1
-----END PGP SIGNATURE-----
Rich Teer

2004-11-19, 5:51 pm

On Fri, 19 Nov 2004, M. B. Trausch wrote:

> I just double-checked, and it's most certainly a typo in the original
> listing. Whoops.


Dontcha just hate books that don't include code from the files
that the author actually uses to test them with?

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
M. B. Trausch

2004-11-19, 5:51 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rich Teer wrote:
|
| Dontcha just hate books that don't include code from the files
| that the author actually uses to test them with?
|

Yeah, ya know? It's kind of insane, just simply because when you're
trying to learn something, you should have a source that is actually
appears to be authoritative... *shrugs*.

In any case, I suppose one typo can be fixed, though, copy/paste when it
comes to examples, is a good thing. If the example out of the book
doesn't compile, what the hell is the point of having the book to teach
someone? :-?

Maybe when I'm a proficient Linux programmer I'll come up with a better
book. Ha! Right.

Later!

~ MT
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBnm6ecNB5yDSBR3oRAkdQAKCglBxFOGvT
C2mxEpqeZEnYivoB3wCeKrH/
YhchW64k48qVSZLSqepSWeA=
=Q13C
-----END PGP SIGNATURE-----
Måns Rullgård

2004-11-19, 5:51 pm

"M. B. Trausch" <fd0man@gmail.com> writes:

> Rich Teer wrote:
> |
> | Dontcha just hate books that don't include code from the files
> | that the author actually uses to test them with?
> |
>
> Yeah, ya know? It's kind of insane, just simply because when you're
> trying to learn something, you should have a source that is actually
> appears to be authoritative... *shrugs*.
>
> In any case, I suppose one typo can be fixed, though, copy/paste when it
> comes to examples, is a good thing. If the example out of the book
> doesn't compile, what the hell is the point of having the book to teach
> someone? :-?


Even worse is when the examples compile, but are buggy. We were a bit
surprised at the university when all the students one year started
doing the same mistake we'd never seen before. The explanation was
that they were using a new edition of the text book, and the new
edition had a bug in one of the examples, the one everyone was
copying.

--
Måns Rullgård
mru@inprovide.com
Rich Teer

2004-11-19, 5:51 pm

On Fri, 19 Nov 2004, M. B. Trausch wrote:

> Yeah, ya know? It's kind of insane, just simply because when you're
> trying to learn something, you should have a source that is actually
> appears to be authoritative... *shrugs*.


Couldn't agree more!

> Maybe when I'm a proficient Linux programmer I'll come up with a better
> book. Ha! Right.


You could always buy mine... :-)

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
M. B. Trausch

2004-11-19, 8:47 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Måns Rullgård wrote:
|
| Even worse is when the examples compile, but are buggy. We were a bit
| surprised at the university when all the students one year started
| doing the same mistake we'd never seen before. The explanation was
| that they were using a new edition of the text book, and the new
| edition had a bug in one of the examples, the one everyone was
| copying.
|

Goodness. That's crazy.

You'd think they'd do better then that. Just goes to show that people
who get to be overconfident, I think, flubber up because they don't
check their stuff ten million times.

~ MT
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBnqwmcNB5yDSBR3oRAl/lAJ41+TAUw3jOZDqRottM4UNVnpkmxwCfYVXP
KPj8eIS1y/AjCeFIP3Oh0w0=
=otFR
-----END PGP SIGNATURE-----
M. B. Trausch

2004-11-19, 8:47 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rich Teer wrote:
|
| You could always buy mine... :-)
|

You're right... care to loan me the money? :-P

(Yes, I'm *that* broke.)

~ MT
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBnqyJcNB5yDSBR3oRApTlAJ0f8bXGC2X6
GwX3SC6Te9esplMfdgCZAWX0
WOgLiD6z1kQzAL9DlGB7m0Y=
=OlWQ
-----END PGP SIGNATURE-----
Rich Teer

2004-11-20, 2:54 am

On Fri, 19 Nov 2004, M. B. Trausch wrote:

> You're right... care to loan me the money? :-P
>
> (Yes, I'm *that* broke.)


So am I... :-(

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
Ian Clarke

2004-11-21, 5:49 pm

Rich Teer <rich.teer@rite-group.com> wrote in message news:<Pine.SOL.4.58.0411191553440.24690@zaphod>...
> On Fri, 19 Nov 2004, M. B. Trausch wrote:
>
>
> Couldn't agree more!
>
>
> You could always buy mine... :-)


Yes, but unfortunately it seems difficult to compile your programs
on Linux, which is what it appears that the poster is aiming at.
Rich Teer

2004-11-21, 5:49 pm

On Sun, 21 Nov 2004, Ian Clarke wrote:

> Yes, but unfortunately it seems difficult to compile your programs
> on Linux, which is what it appears that the poster is aiming at.


Most of them should compile right out of the box, so to speak,
but I don't have a Linux system here to test on. I DID make
sure that the code would compile cleanly on gcc as well as Sun's
compiler.

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
joe@invalid.address

2004-11-21, 8:47 pm

Rich Teer <rich.teer@rite-group.com> writes:

> On Sun, 21 Nov 2004, Ian Clarke wrote:
>
>
> Most of them should compile right out of the box, so to speak,
> but I don't have a Linux system here to test on. I DID make
> sure that the code would compile cleanly on gcc as well as Sun's
> compiler.


It looks like boolean_t is defined in the Solaris system headers, but
not on linux (at least not on RH9). I had some trouble with other
defines and typedefs as well but I don't recall them offhand.

If I get some time this week I'll take another shot at building the
library and send you some diffs if you like.

Joe
--
To the optimist, the glass is half full. To the pessimist, the glass
is half empty. To the engineer, the glass is twice as big as it needs
to be.
- anon
Rich Teer

2004-11-21, 8:47 pm

On Mon, 22 Nov 2004 joe@invalid.address wrote:

> It looks like boolean_t is defined in the Solaris system headers, but
> not on linux (at least not on RH9). I had some trouble with other
> defines and typedefs as well but I don't recall them offhand.
>
> If I get some time this week I'll take another shot at building the
> library and send you some diffs if you like.


Please do. If nothing else, I can add a document to the book's web
site, detailing how to build the examples on Linux. Although I guess
we'd better specify which distro...

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
M. B. Trausch

2004-11-22, 2:47 am

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rich Teer wrote:
| On Sun, 21 Nov 2004, Ian Clarke wrote:
|
|
|>Yes, but unfortunately it seems difficult to compile your programs
|>on Linux, which is what it appears that the poster is aiming at.
|
|
| Most of them should compile right out of the box, so to speak,
| but I don't have a Linux system here to test on. I DID make
| sure that the code would compile cleanly on gcc as well as Sun's
| compiler.
|

*shrugs*

While I am working with Linux, the more that I can grasp about other
UNIX systems, the better. I would much rather learn to write code that
is as portable as possible, right away, then get too dependant on
writing code for just Linux, and then finding that there's some other
POSIX or UNIX something or another that I could've used instead that was
more portable.

~ MT
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBoc0mcNB5yDSBR3oRAiKuAJ0RHpoLOfQ+
n1/lgka1f0uDwDqUUQCfRiT9
QU6eZADTVQbXQJPYmtW/LiQ=
=kEoK
-----END PGP SIGNATURE-----
Trent Buck

2004-11-22, 2:47 am

Quoth joe@invalid.address on or about 2004-11-22:
> It looks like boolean_t is defined in the Solaris system headers, but
> not on linux (at least not on RH9).


For boolean types, C99 specifies:

The <stdbool.h> header shall define the following macros:

bool Expands to _Bool.
true Expands to the integer constant 1.
false Expands to the integer constant 0.
__bool_true_false_are_defined
Expands to the integer constant 1.

An application may undefine and then possibly redefine the macros
bool, true, and false.

IIRC C89 doesn't have this header.

This header exists under Debian/unstable's gcc-4.0, gcc-3.3, gcc-3.4 and
tcc. On a school solaris box I can only see it in gcc, but I could be
looking wrong.

-trent
Måns Rullgård

2004-11-22, 7:49 am

Rich Teer <rich.teer@rite-group.com> writes:

> On Mon, 22 Nov 2004 joe@invalid.address wrote:
>
>
> Please do. If nothing else, I can add a document to the book's web
> site, detailing how to build the examples on Linux. Although I guess
> we'd better specify which distro...


It should be buildable on all distros, of course.

--
Måns Rullgård
mru@inprovide.com
Måns Rullgård

2004-11-22, 7:49 am

"M. B. Trausch" <fd0man@gmail.com> writes:

> While I am working with Linux, the more that I can grasp about other
> UNIX systems, the better. I would much rather learn to write code that
> is as portable as possible, right away, then get too dependant on
> writing code for just Linux, and then finding that there's some other
> POSIX or UNIX something or another that I could've used instead that was
> more portable.


The trick is to avoid anything mentioned as being a GNU extension in
the man pages. The downside is that these extensions are sometimes
quite useful.

--
Måns Rullgård
mru@inprovide.com
Ian Clarke

2004-11-22, 5:51 pm

Rich Teer <rich.teer@rite-group.com> wrote in message news:<Pine.SOL.4.58.0411211925530.24690@zaphod>...
> On Mon, 22 Nov 2004 joe@invalid.address wrote:
>
>
> Please do. If nothing else, I can add a document to the book's web
> site, detailing how to build the examples on Linux. Although I guess
> we'd better specify which distro...


Wait a minute. First you've suggested your book is useful to
someone who's targeting Linux. Then you imply you haven't in
fact (ever??) tested the programs on Linux. And now you start
casting aspersions about portability problems across Linux
distributions. That's diversion: the problem actually seems
to be the portability (or possible lack of it) of your code.
Leaving aside the programs that are targeted at specific
Solaris features, the rest certainly do not seem to compile
"out of the box" on Linux.
Rich Teer

2004-11-22, 5:51 pm

On Mon, 22 Nov 2004, M. B. Trausch wrote:

> While I am working with Linux, the more that I can grasp about other
> UNIX systems, the better. I would much rather learn to write code that
> is as portable as possible, right away, then get too dependant on
> writing code for just Linux, and then finding that there's some other


THat's a very laudable goal. It's also why I recopmmend that you
develop code on some other platform (naturally, I'd recommend
Solaris!), and port TO Linux. For some reason, many Linux developers
have a tendancy to (whether they know it or not) infest their code
with Linuxisms. Consequently, porting TO Linux seems to be an easier
task than porting FROM Linux.

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
Rich Teer

2004-11-22, 5:51 pm

On Mon, 22 Nov 2004, Ian Clarke wrote:

> Wait a minute. First you've suggested your book is useful to
> someone who's targeting Linux. Then you imply you haven't in


It is: MANY of the principles are the same no matter what UNIX
or UNIX-like platform one uses.

> fact (ever??) tested the programs on Linux. And now you start


I'm not implying anything. As of this moment, I've not tested
ANY of the examples on Linux, but I believe that most of them
will build on Linux with no problem (Solaris-specific examples
notwithstanding).

> casting aspersions about portability problems across Linux


Umm, even major SW vendors seem to have a problem with portability
between Linux variants, which is why they say, for example, we
support Red Hat and Mandrake, but nothing else.

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
Måns Rullgård

2004-11-22, 5:51 pm

Rich Teer <rich.teer@rite-group.com> writes:

> On Mon, 22 Nov 2004, Ian Clarke wrote:
>
>
> It is: MANY of the principles are the same no matter what UNIX
> or UNIX-like platform one uses.


The principles may be the same, even when the details differ slightly.

>
> I'm not implying anything. As of this moment, I've not tested
> ANY of the examples on Linux, but I believe that most of them
> will build on Linux with no problem (Solaris-specific examples
> notwithstanding).
>
>
> Umm, even major SW vendors seem to have a problem with portability


The more major, the more problems, in my experience.

> between Linux variants, which is why they say, for example, we
> support Red Hat and Mandrake, but nothing else.


These problems are often with the startup scripts and/or C++ runtime
libraries.

--
Måns Rullgård
mru@inprovide.com
Ian Clarke

2004-11-23, 8:27 am

Rich Teer <rich.teer@rite-group.com> wrote in message

> On Mon, 22 Nov 2004, Ian Clarke wrote:
>
>
> It is: MANY of the principles are the same no matter what UNIX
> or UNIX-like platform one uses.
>
>
> I'm not implying anything. As of this moment, I've not tested
> ANY of the examples on Linux, but I believe that most of them
> will build on Linux with no problem (Solaris-specific examples
> notwithstanding).


Solaris-specific examples notwithstanding, it is not the case.

>
> Umm, even major SW vendors seem to have a problem with portability
> between Linux variants, which is why they say, for example, we
> support Red Hat and Mandrake, but nothing else.


I began by pointing out that your programs don't compile on Linux,
since that was the platform that the original poster mentioned.
You then pointed the conversation in the direction of portability
problems with Linux (distributions), which I found bothersome,
because in this case the portability problems reside elsewhere.

You removed the main point of my last message, so I'll repeat it:
*the problem actually seems to be lack of portability in your
code*. AFAICS, it would take a moderate amount of knowledge
and effort to get your programs to build on any Unix
implementation other than Solaris (where of course it compiles
fine).

Elsewhere in this thread you've said:

On Mon, 22 Nov 2004 17:19:03 GMT, Rich Teer <rich.teer@rite-group.com> wrote:

>On Mon, 22 Nov 2004, M. B. Trausch wrote:
>
>
>THat's a very laudable goal. It's also why I recopmmend that you
>develop code on some other platform (naturally, I'd recommend
>Solaris!), and port TO Linux. For some reason, many Linux developers
>have a tendancy to (whether they know it or not) infest their code
>with Linuxisms. Consequently, porting TO Linux seems to be an easier
>task than porting FROM Linux.


As you point out, targeting one platform is a mistake. But
this is exactly what you have done in your example code: it
appears to contain many unnecessary Solaris dependencies, and
you appear not to know it. How then can you claim that this is a
fault specific to "Linux developers", and chide them for it?
Rich Teer

2004-11-23, 6:08 pm

On Tue, 23 Nov 2004, Ian Clarke wrote:

> Solaris-specific examples notwithstanding, it is not the case.


I'd like to fix this bug (or at least document it). Please could
you post your "make" output? Or, if you prefer, send it to me offline.

Or just say what examples don't build correctly on Linux that ought to.

Or arrange for me to have ssh access to a suitable Linux box, and
I'll do what I can. I don't have a PC here, and I don't want to
blow away one of my Solaris boxes installing Linux on one of them
(I use SPARC).

> You removed the main point of my last message, so I'll repeat it:
> *the problem actually seems to be lack of portability in your
> code*. AFAICS, it would take a moderate amount of knowledge
> and effort to get your programs to build on any Unix
> implementation other than Solaris (where of course it compiles
> fine).


Things like boolean_t aside, I deliberately avoided writing
Solaris-specific code where possible.

> As you point out, targeting one platform is a mistake. But
> this is exactly what you have done in your example code: it
> appears to contain many unnecessary Solaris dependencies, and
> you appear not to know it. How then can you claim that this is a
> fault specific to "Linux developers", and chide them for it?


--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
Rich Teer

2004-11-23, 6:08 pm

On Tue, 23 Nov 2004, Rich Teer wrote:

> Or arrange for me to have ssh access to a suitable Linux box, and
> I'll do what I can. I don't have a PC here, and I don't want to
> blow away one of my Solaris boxes installing Linux on one of them
> (I use SPARC).


Someone has kindly offered me an account on one of their SuSE LInux
servers, so I'm going to try to resolve this.

> Things like boolean_t aside, I deliberately avoided writing
> Solaris-specific code where possible.


Of course, I forgot that Linux doesn't support STREAMS (and its
associated header files), which is (at least partially) why even
the library blows up when one tries to compile it.

What other SVR4 features does Linux lack?

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
Ian Clarke

2004-11-24, 6:28 pm

> > Or arrange for me to have ssh access to a suitable Linux box, and
>
> Someone has kindly offered me an account on one of their SuSE LInux
> servers, so I'm going to try to resolve this.
>

Restating the assertion doesn't change the result.
[vbcol=seagreen]
> Of course, I forgot that Linux doesn't support STREAMS (and its
> associated header files), which is (at least partially) why even
> the library blows up when one tries to compile it.


?? Your library (/lib) code doesn't even use STREAMS.
STREAMS was not the source of the problems I referred to.

> What other SVR4 features does Linux lack?


Why do you keep trying to point the finger at Linux?
Testing on ANY other Unix will show the problems in
the code.
Rich Teer

2004-11-24, 6:28 pm

On Wed, 24 Nov 2004, Ian Clarke wrote:

> ?? Your library (/lib) code doesn't even use STREAMS.
> STREAMS was not the source of the problems I referred to.


You're correct; when I wrote my last post I was thinking that
termios.h was a STREAMS header.

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com