[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: global variables in shared libraries



On Sat, Jan 24, 2004 at 01:59:27PM +0100, martin f krafft wrote:
> also sprach Andrew Suffield <asuffield@debian.org> [2004.01.24.0330 +0100]:
> > I have never seen or heard of a valid use of global variables that
> > could not be done better without using globals. I don't know what
> > you're thinking of for debugging, but for initialisation you
> > either want __attribute__((constructor)), pthread_once(), or
> > a combination of the two.
> 
> I like to control debugging with two variables: the FILE* to the
> stream to which the debugging should be written, and a bitfield so
> see what should be printed.
> 
> If you can think of a better way to do this than using globals, then
> please share it with me!

(somebody else got that)

> Also, I have never seen __attributes__((constructor)) before. Could
> you give me a pointer where I could get more information on this?

gcc manual. Look for function attributes in the index. It's pretty
much identical to a static constructor function in C++.

-- 
  .''`.  ** Debian GNU/Linux ** | Andrew Suffield
 : :' :  http://www.debian.org/ |
 `. `'                          |
   `-             -><-          |

Attachment: signature.asc
Description: Digital signature


Reply to: