public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: Why does this __declspec(dllimport) fail to compile?
@ 2001-08-09 17:42 Danny Smith
  0 siblings, 0 replies; 2+ messages in thread
From: Danny Smith @ 2001-08-09 17:42 UTC (permalink / raw)
  To: Cygwin

To: cygwin at sources dot redhat dot com 
Subject: Why does this __declspec(dllimport) fail to compile? 
From: Mo DeJong <mdejong at cygnus dot com> 
Date: Thu, 9 Aug 2001 02:10:53 -0700 (PDT) 

------------------------------------------------------------------------

The code does compile if use G++.  I think the FAQ you cite says that
MSVC++ also needs to compile as C++

This function is provided by G++ to do the job:
gcc/cp/decl2.c
/* The name of the function we create to handle initializations and
   destructions for objects with static storage duration.  */
#define SSDF_IDENTIFIER "__static_initialization_and_destruction"


Danny
-----------------------------------------------------------------------
Mo DeJong wrote:

Hi.

I have run into a little problem with a static initializer
that seems to work just fine with VC++ but fails with gcc.

% cat callback.c 
extern __declspec(dllimport)
void ExtCallback(void);

typedef void (callback) (void);

typedef struct Scallback {
    callback*c1;
} Scallback;

static Scallback scall = {ExtCallback};

int main() {
    callback*sc = scall.c1;
    return (int) sc;
}

% gcc -c callback.c
callback.c:10: initializer element is not constant
callback.c:10: (near initialization for `scall.c1')

When this same code it compiled with VC++ it waits
until link time to figure out the function address.

Why does this fail with gcc?

P.S.

Other folks have mentioned this python FAQ but
it does not explain why gcc generates this error.

http://www.python.org/doc/FAQ.html#3.24



_____________________________________________________________________________
http://shopping.yahoo.com.au - Father's Day Shopping
- Find the perfect gift for your Dad for Father's Day

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Why does this __declspec(dllimport) fail to compile?
@ 2001-08-09  2:11 Mo DeJong
  0 siblings, 0 replies; 2+ messages in thread
From: Mo DeJong @ 2001-08-09  2:11 UTC (permalink / raw)
  To: cygwin

Hi.

I have run into a little problem with a static initializer
that seems to work just fine with VC++ but fails with gcc.

% cat callback.c 
extern __declspec(dllimport)
void ExtCallback(void);

typedef void (callback) (void);

typedef struct Scallback {
    callback*c1;
} Scallback;

static Scallback scall = {ExtCallback};

int main() {
    callback*sc = scall.c1;
    return (int) sc;
}

% gcc -c callback.c
callback.c:10: initializer element is not constant
callback.c:10: (near initialization for `scall.c1')

When this same code it compiled with VC++ it waits
until link time to figure out the function address.

Why does this fail with gcc?

P.S.

Other folks have mentioned this python FAQ but
it does not explain why gcc generates this error.

http://www.python.org/doc/FAQ.html#3.24

thanks
Mo DeJong
Red Hat Inc

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-08-09 17:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-09 17:42 Why does this __declspec(dllimport) fail to compile? Danny Smith
  -- strict thread matches above, loose matches on Subject: below --
2001-08-09  2:11 Mo DeJong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).