digitalmars.D.announce - ImportC has improved macro support
- Walter Bright (5/5) Dec 06 2023 Macros with the pattern:
- Walter Bright (4/13) Dec 06 2023 The interesting thing here is `expression` does not need to be translate...
- user1234 (5/9) Dec 06 2023 Indeed, I've seen that the other day, the
- Dave P. (3/8) Dec 06 2023 Does this work for function-like macros?
- Walter Bright (2/3) Dec 07 2023 Not yet. It just lays the groundwork for that.
- Ki Rill (11/16) Dec 07 2023 This is amazing! It should solve the disappearing of enum-like
- Walter Bright (3/13) Dec 08 2023 Give it a try, it should work now!
- Paolo Invernizzi (5/25) Dec 09 2023 Same situation here, with RayLib!
Macros with the pattern: #define BOO ( expression ) are now translated to: auto BOO()() { return expression; } and are available for importing!
Dec 06 2023
On 12/6/2023 11:59 AM, Walter Bright wrote:Macros with the pattern: #define BOO ( expression ) are now translated to: auto BOO()() { return expression; } and are available for importing!The interesting thing here is `expression` does not need to be translated to D. It's still a C expression, and has C semantics. D templates with C semantics just falls out of the way ImportC was implemented.
Dec 06 2023
On Wednesday, 6 December 2023 at 20:26:38 UTC, Walter Bright wrote:The interesting thing here is `expression` does not need to be translated to D. It's still a C expression, and has C semantics. D templates with C semantics just falls out of the way ImportC was implemented.Indeed, I've seen that the other day, the [PR](https://github.com/dlang/dmd/pull/15871/files) only modifies the parser.
Dec 06 2023
On Wednesday, 6 December 2023 at 19:59:54 UTC, Walter Bright wrote:Macros with the pattern: #define BOO ( expression ) are now translated to: auto BOO()() { return expression; } and are available for importing!Does this work for function-like macros?
Dec 06 2023
On 12/6/2023 12:43 PM, Dave P. wrote:Does this work for function-like macros?Not yet. It just lays the groundwork for that.
Dec 07 2023
On Wednesday, 6 December 2023 at 19:59:54 UTC, Walter Bright wrote:Macros with the pattern: #define BOO ( expression ) are now translated to: auto BOO()() { return expression; } and are available for importing!This is amazing! It should solve the disappearing of enum-like definitions in code. I encountered this in Raylib. It has colors defined as macros: ```c #define WHITE (Color){255, 255, 255, 255} ``` I preprocessed the file and all color definitions were gone. I had to redefine them manually. Nuklear does the same too for their Flags.
Dec 07 2023
On 12/7/2023 9:17 PM, Ki Rill wrote:This is amazing!All in a day's work!It should solve the disappearing of enum-like definitions in code. I encountered this in Raylib. It has colors defined as macros: ```c #define WHITE (Color){255, 255, 255, 255} ``` I preprocessed the file and all color definitions were gone. I had to redefine them manually.Give it a try, it should work now!
Dec 08 2023
On Friday, 8 December 2023 at 05:17:30 UTC, Ki Rill wrote:On Wednesday, 6 December 2023 at 19:59:54 UTC, Walter Bright wrote:Same situation here, with RayLib! I really really like the way importC is improving, kudos to Walter! /PaoloMacros with the pattern: #define BOO ( expression ) are now translated to: auto BOO()() { return expression; } and are available for importing!This is amazing! It should solve the disappearing of enum-like definitions in code. I encountered this in Raylib. It has colors defined as macros: ```c #define WHITE (Color){255, 255, 255, 255} ``` I preprocessed the file and all color definitions were gone. I had to redefine them manually. Nuklear does the same too for their Flags.
Dec 09 2023