Amanda-Users

Re: Compiling 2.4.4p1 with gcc on SunOs 4.1.3

2003-10-01 12:49:38
Subject: Re: Compiling 2.4.4p1 with gcc on SunOs 4.1.3
From: Jon LaBadie <jon AT jgcomp DOT com>
To: amanda-users AT amanda DOT org
Date: Wed, 1 Oct 2003 12:46:19 -0400
On Wed, Oct 01, 2003 at 06:28:07PM +0200, Paul Bijnens wrote:
> Julian C H Stevens wrote:
> 
> >Thanks for the tip, John.
> >
> >My getopt man page states that getopts is preferred, so I have
> >modified the source to use getopts instead. I am re-running make but,
> >as you may have guessed, my sun workstation is a little s-l-o-w! 
> >...I'll report back when its finished.
> 
> 
> Nonono.  That is the shell utility getopts vs getopt.
> Do "man 3 getopt" to get the page for the C library routines.
> 
> And there you find:
> 
> SYNOPSIS
>      int getopt(argc, argv, optstring)
>      int argc;
>      char **argv;
>      char *optstring;
> 
>      extern char *optarg;
>      extern int optind, opterr;
> 
> So what you need actually is a definition for optind, that seems
> to be missing:
> 
> Add somewhere in main() or outside it the defintion:
> 
>     extern int optind;
> 
> What I do not know exactly is why gcc doesn't complain on other
> OSes about the missing declaration.  (in amanda.h I find the
> definition for getopt and optarg, but not for optind; actually
> you better add the definition there.)
> 

Again, this is for Solaris, not SunOS;

Sun's man needs the -s option to see other sections and getopt is in 3c.
So the command would be "man -s 3c getopt".

It indicates that optind and the others are defined in <unistd.h>.
So possibly that should be included in your source somewhere (amanda.h?).
-- 
Jon H. LaBadie                  jon AT jgcomp DOT com
 JG Computing
 4455 Province Line Road        (609) 252-0159
 Princeton, NJ  08540-4322      (609) 683-7220 (fax)