Giter Site home page Giter Site logo

Comments (9)

jacob-carlborg avatar jacob-carlborg commented on June 22, 2024

DStep turned it into this, removing the const for the second parameter

This looks a bit odd. But according to libclang, which DStep uses under the hood, state is not const.

I haven't checked to see if dmd will actually complain about this

Why would DMD complain about this?

from dstep.

jacob-carlborg avatar jacob-carlborg commented on June 22, 2024

Hmm, if I remove the typedef, i.e. during it into a variable declaration, libclang will see it as const.

from dstep.

jacob-carlborg avatar jacob-carlborg commented on June 22, 2024

I've asked about this on the Clang mailing list.

from dstep.

joakim-noah avatar joakim-noah commented on June 22, 2024

Why would DMD complain about this?

Because the callback signature doesn't match the C library? I've had that happen in other situations, not sure if it would here. If you mean that it's the linker that normally catches stuff like this, sure.

Hmm, if I remove the typedef, i.e. during it into a variable declaration, libclang will see it as const.

Yeah, if you turn it into an actual function declaration, it sees the parameter as const, just not when it's a function pointer.

from dstep.

jacob-carlborg avatar jacob-carlborg commented on June 22, 2024

Because the callback signature doesn't match the C library? I've had that happen in other situations, not sure if it would here. If you mean that it's the linker that normally catches stuff like this, sure.

Right, when you use the function pointer. Yes, then DMD will complain.

Yeah, if you turn it into an actual function declaration, it sees the parameter as const, just not when it's a function pointer.

It's not the function pointer that is the problem, it's the typedef.

from dstep.

jacob-carlborg avatar jacob-carlborg commented on June 22, 2024

I got a reply [1] from the mailing list and this is apparently how C behaves. I'm not sure that I can do anything about it.

[1] http://clang-developers.42468.n3.nabble.com/const-stripped-in-typedefs-for-parameters-of-primitive-type-td4041337.html

from dstep.

jacob-carlborg avatar jacob-carlborg commented on June 22, 2024

Perhaps D should allow the callbacks anyway since const doesn't really matter for value types.

from dstep.

joakim-noah avatar joakim-noah commented on June 22, 2024

I have no real inclination on what to do here, I wasn't even sure it was a bug. I just reported it as I was double-checking the translation and it seemed like it might be.

from dstep.

jacob-carlborg avatar jacob-carlborg commented on June 22, 2024

It behaves as it should according to C. But that will cause problems on the D side. I really, really don't want to parse C code without the help of Clang.

from dstep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.