Is overloading (union) structures available?

  1. 4 months ago

    Eugene D

    Jul 13 Pre-Release Testers, Xojo Pro Canada scispec.ca

    Is there a way to overload (union) structures?

    I am working on some declare's with structures that are overloaded - or in Windows parlance are Union. The structure is IN_ADDR which is used in Sockets: IN_ADDR

    struct in_addr {
      union {
        struct {
          u_char s_b1;
          u_char s_b2;
          u_char s_b3;
          u_char s_b4;
        } S_un_b;
        struct {
          u_short s_w1;
          u_short s_w2;
        } S_un_w;
        u_long S_addr;
      } S_un;
    };

    There is a conversation from a couple of years ago which shows a way to make different structures just by adding different values (1, 2, etc.) at c-style-unions-in-xojo .

    If nothing has changed then I'll just use the different suffix number. Does anyone have a way to make overloading (union) structures work in Xojo?

    Thanks :)

    Not that I'm aware of, you need to make separate structs and use them in the right place or as the post mentions detect which is needed, usually by data in the struct then use the right one.

  2. Julian S

    Jul 13 Pre-Release Testers, Xojo Pro Answer UK

    Not that I'm aware of, you need to make separate structs and use them in the right place or as the post mentions detect which is needed, usually by data in the struct then use the right one.

  3. Eugene D

    Jul 13 Pre-Release Testers, Xojo Pro Canada scispec.ca

    Thanks Julian!

  4. Norman P

    Jul 13 Pre-Release Testers, Xojo Pro
    Edited 4 months ago

    Heh
    I was just about to write a blog post with a "How To" and see that your following my old post anyway :)

    Would seem this should be in an "Advanced Guide" but the "Advanced Guide" in the docs doesnt mention that at all

or Sign Up to reply!