Date: Fri, 17 May 2002 04:22:46 +0200 From: Bernd Walter <ticso@cicely5.cicely.de> To: Albert Kinderman <albert.kinderman@csun.edu> Cc: freebsd-hackers@FreeBSD.org Subject: Re: c++ and dlerror(): Linux vs FreeBSD Message-ID: <20020517022245.GF34611@cicely5.cicely.de> In-Reply-To: <3CE456DA.8010200@csun.edu> References: <3CE456DA.8010200@csun.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020517022245.GF34611>
