Thread overview
[Issue 24094] importC __declspec issues
Aug 20, 2023
Basile-z
Aug 22, 2023
Walter Bright
Aug 25, 2023
Michael Barth
Aug 25, 2023
Michael Barth
[Issue 24094] importC __declspec not working in front of declaration statement
Nov 02, 2023
Walter Bright
Nov 02, 2023
Dlang Bot
Nov 02, 2023
Dlang Bot
August 20, 2023
https://issues.dlang.org/show_bug.cgi?id=24094

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ImportC

--
August 22, 2023
https://issues.dlang.org/show_bug.cgi?id=24094

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
I tried the following:

------------ test.c -----------
__declspec(allocator) __declspec(restrict)
 void* __cdecl _calloc_base(int, int);
-------------------------------

and it compiled without error. Can you perhaps try your code with the latest compiler? I note that __declspec(restrict) was a newer addition to dmd.

--
August 25, 2023
https://issues.dlang.org/show_bug.cgi?id=24094

--- Comment #2 from Michael Barth <spirrwell@yahoo.com> ---
(In reply to Walter Bright from comment #1)
> I tried the following:
> 
> ------------ test.c -----------
> __declspec(allocator) __declspec(restrict)
>  void* __cdecl _calloc_base(int, int);
> -------------------------------
> 
> and it compiled without error. Can you perhaps try your code with the latest compiler? I note that __declspec(restrict) was a newer addition to dmd.

Hm, my bad. I guess I was literally just a few versions behind. It does compile with the latest DMD. It looks like it also compiles with the latest beta version of LDC2 as well.

There is one more __declspec issue I've come across that is still present as of DMD v2.105.0.

Error: found `__declspec` instead of statement

This error seems to happen with the following code:

void fun() {
        __declspec(align(16)) short data[64];
}

This does not happen if the variable is in global scope or part of a struct. As far as I've tested, it only occurs if the variable is declared inside a function body.

--
August 25, 2023
https://issues.dlang.org/show_bug.cgi?id=24094

Michael Barth <spirrwell@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spirrwell@yahoo.com

--
November 02, 2023
https://issues.dlang.org/show_bug.cgi?id=24094

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86_64                      |All
            Summary|importC __declspec issues   |importC __declspec not
                   |                            |working in front of
                   |                            |declaration statement
                 OS|Windows                     |All

--
November 02, 2023
https://issues.dlang.org/show_bug.cgi?id=24094

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #15773 "fix Issue 24094 - importC __declspec not working in front of declarat…" fixing this issue:

- fix Issue 24094 - importC __declspec not working in front of declaration statement

https://github.com/dlang/dmd/pull/15773

--
November 02, 2023
https://issues.dlang.org/show_bug.cgi?id=24094

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15773 "fix Issue 24094 - importC __declspec not working in front of declarat…" was merged into master:

- 77ce3096cbebdf6f436a50973ab254118f3e18a5 by Walter Bright:
  fix Issue 24094 - importC __declspec not working in front of declaration
statement

https://github.com/dlang/dmd/pull/15773

--