is there a more transparent way to use a C float*

About Monkey 2 Forums Monkey 2 Programming Help is there a more transparent way to use a C float*

This topic contains 5 replies, has 2 voices, and was last updated by  codifies 2 years, 2 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #6822

    codifies
    Participant

    This is really just a sanity check as I’m not terribly satisfied with the fugliness I’ve come up with (hoping I’ve missed a trick or forgotten something)…

    [/crayon]

    When I want a mx2 float pointer from this function I’m doing

    [/crayon]

    Which just seems a little less satisfying than it could be ? (especially the cfloat “struct”)

    although the parser is fine with me using float ptr in the prototype (instead of cfloat ptr) it misses the issue this causes with the compiler (basically it can’t cast a float* to bb_float* I’m hoping this is where I’m missing a possible clue)

    #6841

    Mark Sibly
    Keymaster

    Not sure why you’re bothering with the cfloat struct at all there…

    mx2 floats *are* just c floats (ie: 32bit) and mx2 doubles are just c doubles (ie: 64bit) – in fact, your code already depends on this as it’s casting cfloat ptr to float ptr – so the cfloat struct is redundant as far as I can see.

    #6846

    codifies
    Participant

    I just got errors about not being able to cast a float* for a bbfloat* or similar – there does seem to be differences between mingw gcc and more up to date versions (v6.3.0 here)

    I’ll try again and see if I can induce the error…

    #6847

    codifies
    Participant
    [/crayon]

    ah hang on it itsn’t that const thing again is it?

    #6871

    Mark Sibly
    Keymaster

    Yes, looks like a const thing. Your initial solution is probably as good as it gets without resorting to native glue code, which would be cleaner but a little trickier.

    #6873

    codifies
    Participant

    wouldn’t this add over head ? – ie two calls per API call rather than 1 ? (but I might have misunderstood!)

    also I assume

    [/crayon]

    is more technically correct but out of interest will it actually make any difference ?

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.