From owner-freebsd-hackers Thu May 16 19:23:14 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from srv1.cosmo-project.de (srv1.cosmo-project.de [213.83.6.106]) by hub.freebsd.org (Postfix) with ESMTP id CF7B337B405 for ; Thu, 16 May 2002 19:23:06 -0700 (PDT) Received: from cicely5.cicely.de (cicely5.cicely.de [IPv6:3ffe:400:8d0:301:200:92ff:fe9b:20e7]) (authenticated bits=0) by srv1.cosmo-project.de (8.12.3/8.12.3) with ESMTP id g4H2MwHc014009 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Fri, 17 May 2002 04:23:00 +0200 (CEST) (envelope-from ticso@cicely5.cicely.de) Received: from cicely5.cicely.de (localhost [IPv6:::1]) by cicely5.cicely.de (8.12.1/8.12.1) with ESMTP id g4H2Mk95038255 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Fri, 17 May 2002 04:22:46 +0200 (CEST)?g (envelope-from ticso@cicely5.cicely.de) Received: (from ticso@localhost) by cicely5.cicely.de (8.12.1/8.12.1/Submit) id g4H2Mkb4038254; Fri, 17 May 2002 04:22:46 +0200 (CEST)?g (envelope-from ticso) Date: Fri, 17 May 2002 04:22:46 +0200 From: Bernd Walter To: Albert Kinderman Cc: freebsd-hackers@FreeBSD.org Subject: Re: c++ and dlerror(): Linux vs FreeBSD Message-ID: <20020517022245.GF34611@cicely5.cicely.de> References: <3CE456DA.8010200@csun.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3CE456DA.8010200@csun.edu> User-Agent: Mutt/1.3.26i X-Operating-System: FreeBSD cicely5.cicely.de 5.0-CURRENT i386 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, May 16, 2002 at 06:03:22PM -0700, Albert Kinderman wrote: > Disclaimer: I am not a programmer! > > I am trying to compile scribus-0.7.2, a Page Layout program, built > against qt3. /usr/ports/print/scribus contains scribus-0.5, which > is the qt2 version. > > On my Debian GNU/Linux, make works without a hitch. On my FreeBSD > stable box, I get a series of errors of the following type: > > scribus.cpp:4217: assignment to `char *' from `const char *' > discards qualifiers > scribus.cpp: In method `int ScribusApp::DLLType(QString)': > scribus.cpp:4240: assignment to `char *' from `const char *' > discards qualifiers > *** Error code 1 > > Stop in /usr/local/scribus-0.7.2/scribus > > These errors come from code similar to code that is given as an > example of how to handle exceptions in the Linux man page for > dlerror, /usr/compat/linux/man/man3/dlopen.3 Specifically, the > last error was produced by > > int ScribusApp::DLLType(QString name) > { > void *mo; > char *error; > typedef int (*sdem0)(); > sdem0 demo; > QString pfad = PREL; > pfad += "/share/scribus/plugins/" + name; > mo = dlopen(pfad, RTLD_LAZY); > if (!mo) > return 0; > dlerror(); > demo = (sdem0)dlsym(mo, "Type"); > if ((error = dlerror()) != NULL) <-- line 4240 > { > dlclose(mo); > return 0; > } > int an = (*demo)(); > dlclose(mo); > return an; > } > > > Both the FreeBSD and the Linux man pages list > > const char *dlerror(void) > > Why does c++ on FreeBSD produce an error on > error = dlerror() > and c++ on Debian Linux does not? What is the proper fix? Either you don't compile with warnings enabled on Linux or Linux doesn't declare dlerror returning a const char*. Nevertheless the manpage function declaration says that you should have defined your error variable as a const char* too. In fact the error variable is written only, which obsoletes it anyway. You could just do: if (dlerror() != NULL) -- B.Walter COSMO-Project http://www.cosmo-project.de ticso@cicely.de Usergroup info@cosmo-project.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message