Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!news.cs.indiana.edu!msi.umn.edu!cs.umn.edu!umn-cs!meuer From: meuer@cs.umn.edu (Mark V. Meuer) Newsgroups: comp.sys.sgi Subject: Re: getopt and C++ Keywords: Problem Message-ID: <1991Mar4.171251.3502@cs.umn.edu> Date: 4 Mar 91 17:12:51 GMT References: <1991Mar04.161843.27932@cs.ruu.nl> Sender: news@cs.umn.edu (News administrator) Reply-To: meuer@cs.umn.edu (Mark V. Meuer) Organization: University of Minnesota, Minneapolis, CSci dept. Lines: 23 Nntp-Posting-Host: pico.cs.umn.edu In article <1991Mar04.161843.27932@cs.ruu.nl>, markov@cs.ruu.nl (Mark Overmars) writes: > I have a simple question: How do I use the routine getopt with C++. What I did > was to put > > extern int getopt(int,char **,char *); > > in the program. Now the loader complaints that getopt__FiPPcPc is undefined. > > How do I solve this? > > Mark Overmars I *think* all you have to do is change the declaration to extern "C" { extern int getopt(int,char **,char *); } ; and it should work correctly. In general, when calling a C function, put the declarations in a block preceeded by 'extern "C"' and life should be wonderful. -mark