(linenum→info "unix/slp.c:2238")

Daiki Ueno

2008-01-15

openssl/0.9.8g/e_os2.h:253-267

  253: /* Macros to allow global variables to be reached through function calls when
  254:    required (if a shared library version requvres it, for example.
  255:    The way it's done allows definitions like this:
  256: 
  257:         // in foobar.c
  258:         OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0;
  259:         // in foobar.h
  260:         OPENSSL_DECLARE_GLOBAL(int,foobar);
  261:         #define foobar OPENSSL_GLOBAL_REF(foobar)
  262: */
  263: #ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION
  264: # define OPENSSL_IMPLEMENT_GLOBAL(type,name)                         \
  265:         extern type _hide_##name;                                   \
  266:         type *_shadow_##name(void) { return &_hide_##name; }        \
  267:         static type _hide_##name

グローバル変数を extern で宣言して (265)、static で定義している (267)。 mingw32 の gcc でこけます。 やりたいことは分かるんだけど。。