 |
|
|
 |
|
 |
Exactly what's needed for a win project and in the public domain.
|
|
|
|
 |
|
 |
Just looking for a windows version getopt.
Thanks for your help.
|
|
|
|
 |
|
 |
It does not clear state between loops. Thus,
while (...getopt...) { ... }
optind = 1
while (...getopt...) { ... }
will fail. I have to take away a star for that one. I had to write my own impl now, boo hoo :(
|
|
|
|
 |
|
 |
Problems wrt unix standard getopt:
1. optopt is not supported.
2. opterr is declared but not defined or used. The code behaves as if opterr is 0, ie. no error messages are written.
3. optind is supposed to be 1 before first call to getopt. Here it is 0. FWIW the doc does mention this. (*)
4. optind is not supposed to change for "together" options, as it is supposed to be the index of the next arg to be processed. For example, for "exec -ab" (both -a, -b are options), optind is supposed to be 1 after -a is processed; thus 1 before (from 3. above), 1 after. Here it is 0 before, 2 after.
I'm sorry, but standard compatibility is 80% of the work of such low level code. OTOH lack of it makes it a true MS getopt
(*) The reason optind is 1 is because argv starts to be processed at index optind, which works out well for command line args. At least I can use a 'standard' getopt for any set of such args (which dont have the 'program name' in front) by simply presetting optind to 0. With this implementation, I cannot do anything other than prefixing a dummy argument to my array.
modified on Tuesday, February 24, 2009 3:19 PM
|
|
|
|
 |
|
|
 |
|
 |
U save us kinda lot of time.
I am just wondering why I can't find getopt from MSDN.
Thanks
Jim Chung
|
|
|
|
 |
|
 |
As the title says - useful bit of code - cheers!
PC
|
|
|
|
 |
|
 |
thanks veryvery much,i cant find getopt() in .net 2003 but its OK now,thank U very much
but can i copy the soucecode from linux?
|
|
|
|
 |
|
 |
I'm brand new to C programming. My first project involves converting an old Unix C program to Windows. Right now, I'm trying to make a simple program that uses XGetopt, but I
keep getting errors. I'm using Borland C++ 5.01
Here's the errors I'm getting:
Info :xgetopt.cpp: output file xgetopt.obj does not exist
Info :Compiling C:\Documents and Settings\epajn\Desktop\parser\getopt\test\xgetopt.cpp
Error: STDAFX.H(11,2):Unable to open include file 'afxwin.h'
Error: STDAFX.H(12,2):Unable to open include file 'afxext.h'
Error: STDAFX.H(13,2):Unable to open include file 'afxdtctl.h'
Error: STDAFX.H(15,2):Unable to open include file 'afxcmn.h'
Warn : XGETOPT.H(18,1):Redefinition of '_MT' is not identical
Error: XGETOPT.H(19,15):Declaration syntax error
Error: XGETOPT.H(21,29):Type name expected
Error: xgetopt.cpp(155,3):Declaration syntax error
Error: xgetopt.cpp(158,29):Type name expected
Any help would be greatly appreciated. Sorry for the ignorance
|
|
|
|
 |
|
 |
You can find getopt() source code on your MSDN Library Disc 2.
Just search for 'getopt' under the 'Search' tab. You will get GETOPT.C
and GETOPT.H in the search result. The source code is available by IBM Corporation on an AS IS basis, and I believe it works well.
Zele
|
|
|
|
 |
|
 |
Can you tell me on which edition of MSDN CD can I find the
source code of getopt?
I searched it on MSDN April 2003.
-Amey
|
|
|
|
 |
|
 |
It is in MSDN Library you've got with Visual Studio 6.0
|
|
|
|
 |
|
 |
Thank you very much for striking out and writing this! It is much apreciated!
Dave
|
|
|
|
 |
|
 |
It would be nice if it supported non option arguments ANYWHERE in the command line, not only as the last one.
|
|
|
|
 |
|
 |
This is one of limitations listed in XGetopt.cpp header: " 5) The automatic permutation of arguments is not supported."
If you would like, please feel free to add this to XGetopt.
Best wishes,
Hans
|
|
|
|
 |
|
 |
Thanks!!;)
Please pardon my weak English!
|
|
|
|
 |
|
 |
Nish
Bow wow wow,
Yippee yo yippee yay,
My miniputt high,
Is now 30 yay.
|
|
|
|
 |
|
 |
Its probably a useful thing to give a quick descriptio of what GetOpt is fro people who don't know. I had to have a think, because I've not touched Unix in a couple of years, but could see that this is a really useful little tool one I reminded myself.
Good Stuff.
Thanks,
Giles
|
|
|
|
 |
|
 |
Ignore that, I did not spot the section below the Title - would have made life easier for myself.
Giles
|
|
|
|
 |
|
 |
Don't we all do that
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
†
|
|
|
|
 |
|
 |
Yep, I can belive I'm not the only one who's done it.
Giles
|
|
|
|
 |