[Issue 935] New: Extern Global C Variables

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 6 09:04:09 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=935

           Summary: Extern Global C Variables
           Product: D
           Version: 1.00
          Platform: PC
               URL: http://www.digitalmars.com/d/htomodule.html
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P3
         Component: www.digitalmars.com
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: torhu at yahoo.com


Under the heading 'Extern Global C Variables', it's explained that you need to
create an extra module that is not linked with, in order to avoid a multiple
definition error.

But given a C header file:

struct Foo { };
struct Foo bar;

It's enought just to have a single module, like this:

struct Foo { }
extern extern (C) Foo bar;

The first 'extern' makes bar a pure declaration, and the definition in the C
library will be used.  Tested with dmd 1.0 and 1.004.


-- 



More information about the Digitalmars-d-bugs mailing list