Giter Site home page Giter Site logo

Typedefs and function pointers about dstep HOT 10 CLOSED

aldanor avatar aldanor commented on July 21, 2024
Typedefs and function pointers

from dstep.

Comments (10)

aldanor avatar aldanor commented on July 21, 2024

... so that should probably be converted to:

alias tibrvMsgData_Encoder = tibrv_status function(
    char** wire_buffer, tibrv_u32 mem_available, tibrvMsgField* field);

from dstep.

jacob-carlborg avatar jacob-carlborg commented on July 21, 2024

Clang cannot compile that code, that's also what the error says 😉. It seems it cannot find tibrv_status. I think Clang uses int here as a form of default type.

from dstep.

aldanor avatar aldanor commented on July 21, 2024

Oh, so that could have happened because I was converting each header one by one? The status thing is just a typedef defined in another header that gets included. This hasn't caused problems with anything but this issue though.

from dstep.

jacob-carlborg avatar jacob-carlborg commented on July 21, 2024

You basically need to convert the headers one by one. That's only what's currently supported by DStep. C is a very annoying language in this area. If a given header is always included together with other headers it could very well be that this header is using symbols from other headers but is not explicitly including them itself. Personally I would say that is a broken design.

If this is the case I would recommend you contribute a fix to the project, if it's open source. Otherwise you could just add the missing includes when running DStep on the files and then remove them.

Hmm, I'm wondering if it's not able to find a header file, but in that case it would say so. In that case you need to use the -I flag to indicate where it can find the header files.

I just noticed that Clang has the a flag that could be useful

-include <file>         Include file before parsing

from dstep.

aldanor avatar aldanor commented on July 21, 2024

Yea. I wonder if one could figure out a correct merge order based on local #include "..." directives from a set of header files? And then just dump everything into a single huge D module. There's many issues if you do it one by one and then try to merge it manually -- for instance, I had to fix a good number of Anonymous_0, Anonymous_1 name clashes (see #8). Or issues like the one above.

from dstep.

jacob-carlborg avatar jacob-carlborg commented on July 21, 2024

I updated my comment above.

from dstep.

jacob-carlborg avatar jacob-carlborg commented on July 21, 2024

The idea is that you should not merge the D modules. You need to manually add import-statements instead. That's something DStep doesn't handle automatically.

from dstep.

aldanor avatar aldanor commented on July 21, 2024

In regards to the original question, indeed, the tibrv_status was defined in the file that wasn't directly included in the target header file (status.h), so one would need to pass the -include flag, as @jacob-carlborg has pointed out above:

dstep handler.h -o handler.d -include status.h

which would then correctly generate

extern(C):

alias  function (char**, uint, tibrvMsgField*) tibrvMsgData_Encoder;

Perhaps this could be put in the docs as it happens very often in C libraries.

from dstep.

jacob-carlborg avatar jacob-carlborg commented on July 21, 2024

Personally I think this is a workaround and not a solution. I think it's a broken design of the header files. But I put it in the documentation anyway.

from dstep.

jacob-carlborg avatar jacob-carlborg commented on July 21, 2024

@aldanor I added a section for limitations/known issue to the readme: https://github.com/jacob-carlborg/dstep#limitationsknown-issues.

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.