getopt()

K

k_over_hbarc

What is the correct format of getopt() and how does it work? I looked
at the man page; it doesn't really clarify things. What's a program
that uses it, maybe I could figure it out from that.

Note: This is on-topic. getopt is part of the standard library.

Andrew Usher
 
A

Arthur J. O'Dwyer

[fups set to c.p]

What is the correct format of getopt() and how does it work? I looked
at the man page; it doesn't really clarify things. What's a program
that uses it, maybe I could figure it out from that.

man 3 getopt
(is not the same as)
man getopt
Note: This is on-topic. getopt is part of the standard library.

Note: getopt is certainly *NOT* part of the standard library; I don't
know where you got that idea. Questions such as yours which are not
related to ISO standard C should be directed to a group where they'd be
on-topic, such as comp.programming, one of the gnu. hierarchy, or perhaps
a Linux programming group.

-Arthur
 
K

Keith Thompson

??? It is in libc. Maybe it's Unix-specific, but C is Unix.

libc is not the standard C library (i.e., the library defined by the C
language standard).

C is a language; Unix is an operating system. C is not Unix; Unix is
not C.
 
K

k_over_hbarc

Keith said:
libc is not the standard C library (i.e., the library defined by the C
language standard).

That library doesn't exist! The only C is the one people actually use.
I don't care for bureaucratic s*** here more than anywhere else.
C is a language; Unix is an operating system. C is not Unix; Unix is
not C.

I know that, obviously. But C is written for Unix and vice versa.

Andrew Usher

P.S. As far as getopt(), I wrote some test programs and I think I have
figured it out. It doesn't really work well with a ':' other than at
the end, though. I think anyone who's serious about processing command
lines would write his own modification.
 
K

Keith Thompson

That library doesn't exist! The only C is the one people actually use.
I don't care for bureaucratic s*** here more than anywhere else.

The topic of this newsgroup is the C language as defined by the
standard (which doesn't include getopt). If you want to discuss
something else, there are other newsgroups; in comp.unix.programmer,
for example, they're far more likely to be able to answer your
questions than we are.
 
S

slebetman

but C is Unix.

So what do you call Windows3.1 then? Unix??? It certainly was written
in C as much as any variant of Unix were.

I've written on systems where their libc includes support for CANbus
and ARCnet but I recognise that they were vendor specific additions to
libc. Just because gcc has its own extended libc doesn't mean that ALL
C compilers need to emulate it to conform to C standards (ANSI, C99,
etc).
 
N

Nick Keighley

Keith Thompson wrote:

That library doesn't exist! The only C is the one people actually use.
I don't care for bureaucratic s*** here more than anywhere else.

did you notice that you are the only person in this thread that thinks
that. Could it
perhaps be that you are wrong?

<snip>
 
M

Malcolm

That library doesn't exist! The only C is the one people actually use.
I don't care for bureaucratic s*** here more than anywhere else.
It is not just bureaucratese.
If write a program in ANSI C, then you can guarantee that it will compile
and run on any system with a ANSI C compiler. If it doesn't you can complain
to the compiler vendor, and he will either have to post a fix or remove the
claim to ANSI compatibility.
On the other hand if you use a non-standard function like getopt(), you may
end up having to implement it youself. There is no getopt() on my Windows C
compiler, for instance.
I know that, obviously. But C is written for Unix and vice versa.
They grew up together. And C works more nicely on Unix than any other
system. However only a minority of my C programs have been for Unix - most
are either Windows or games console programs.
 
M

Mike Wahler

Keith Thompson said:
libc is not the standard C library (i.e., the library defined by the C
language standard).

C is a language; Unix is an operating system. C is not Unix;

Let's start the CNU movement! :)

-Mike
 
W

William Ahern

What is the correct format of getopt() and how does it work? I looked
at the man page; it doesn't really clarify things. What's a program
that uses it, maybe I could figure it out from that.
Note: This is on-topic. getopt is part of the standard library.

getopt is defined in the Standard Unix Specification, not ANSI C.
The online SUSv3 description has example usage:

http://www.opengroup.org/onlinepubs/009695399/functions/getopt.html

And of course, there are about a gazillion Free Software programs out there
that use getopt, all with viewable, usable and redistributable source code.

Direct any questions to comp.unix.programmer.
 
M

Mark McIntyre

I know that, obviously. But C is written for Unix and vice versa.

Maybe once upon a time, C was targettted at an early version of unix ,
but that was 30-odd years ago. Unix certainly was never written for
C.
The first proper rockets were targetted at london, does that make the
shuttle 'for' london, and vice-versa?
 
D

Default User

That library doesn't exist! The only C is the one people actually use.
I don't care for bureaucratic s*** here more than anywhere else.


Annnnnnd *plonk*.



Brian
 
K

Kenneth Brody

That library doesn't exist! The only C is the one people actually use.

Well, there's no such thing as "the one people actually use", because
there is no "the" C compiler. There are many C compilers available, and
most (if not all) include extensions to the standard. Those extensions
(of which getopt is one) are off-topic here.

There is, however, something called "the" C language, and that is what
is discussed here. (Well, there have been several revisions to "the"
language.)

And, one of the C compilers that I actually use shows:

==========
C:\temp>cl foo.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

foo.c
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:foo.exe
foo.obj
foo.obj : error LNK2001: unresolved external symbol _getopt
foo.exe : fatal error LNK1120: 1 unresolved externals
==========
I don't care for bureaucratic s*** here more than anywhere else.

And off-topic posts aren't welcome here more than anywhere else.

I can hear a lot of plonking going on over that sentence.
I know that, obviously. But C is written for Unix and vice versa.

Since when? C, as defined in the standard and discussed in this group,
doesn't even require an O/S. (It doesn't even require a keyboard and
display.)
P.S. As far as getopt(), I wrote some test programs and I think I have
figured it out. It doesn't really work well with a ':' other than at
the end, though. I think anyone who's serious about processing command
lines would write his own modification.

Or ask for help in a group where this discussion is not off-topic.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:[email protected]>
 
C

Christopher Benson-Manica

Mike Wahler said:
Let's start the CNU movement! :)

Or, perhaps the analagous UNC movement, but that would not be popular
with Duke fans, I'm afraid... :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top