On Feb 29, 2008, at 6:39 AM, Török Edwin wrote: > Keith Bauer wrote: >> On Fri, Feb 29, 2008 at 7:18 PM, Chris Lattner <[EMAIL PROTECTED]> >> wrote: >> >>> Actually, dladdr seems useful on unix'y systems. Does this work on >>> linux? >>> >> >> A quick trip to Google suggests that dladdr is nonstandard, >> implemented on Solaris, Linux (glibc), Mac OS X, maybe FreeBSD, >> definitely not OpenBSD. > > It depends on OpenBSD version, on 4.2 it works[*], but only if you > pass > an address of a symbol from a dynamic libray, not the main executable. > So this works: > $ gcc -shared p.c -o p.so > $ gcc p.so > $ LD_LIBRARY_PATH=. ./a.out > 1 > ./p.so
Okay, I just checked in the makefile support and a very simple, but working, solution using dladdr. It should build on all platforms, but won't work in some cases (such as this above). I'd appreciate it if people could help improve the sys::Path::GetMainExecutable to work on their hosts. Also, I now get this warning from G++: clang.cpp:883: warning: ISO C++ forbids casting between pointer-to- function and pointer-to-object This is true, but not very helpful. I'm not sure how to work around this other than not building with -pedantic. A simple test: $ echo "#include <stdbool.h>" | clang -E -C | grep Eli * Copyright (c) 2008 Eli Friedman -Chris _______________________________________________ cfe-dev mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
