Hi Jonathan,

W dniu 28.06.2023 o 09:31, Jonathan Wakely pisze:


On Wed, 28 Jun 2023, 08:14 Rafał Pietrak via Gcc, <gcc@gcc.gnu.org
[---------]
    how it looks like. I have a lot of code like this scattered around:
    -------------------
                                     y->next = NULL;
                     if (our) { out->next = a;
                     for (y = t->HD; y && y->next; y = y->next)
                     if (y)  y->next = a;
                             fit->HD = a->next;
                     fit->win = a->next;
                             b = a->next;
    --------------------
    This is from just one source file, which otherwise is "plain C". If I
    was to put it into a library that use "asm tweaked fancy pointers", a
    portable fragment of code becomes "target dedicated" - this is
    undesired.


If you use a C++ library type for your pointers the syntax above doesn't need to change, and the fancy pointer type can be implemented portable, with customisation for targets where you could use 16 bits for the pointers.

As you can expect from the problem I've stated - I don't know C++, so I'll need some more advice there.

But, before I dive into learning C++ (forgive the naive question).... isn't it so, that C++ comes with a heavy runtime? One that will bloat my tiny project? Or the bloat comes only when one uses particular elaborated class/inheritance scenarios, and this particular case ( for (...; ...; x = x->next) {} ) will not draw any of that into this project?

Not knowing C++ and wanting to check your suggestion (before I start putting time into learning it), can you pls provide me a sample of code, that would replace the following:
----------------
struct test_s {
        struct test_s *next;
        char buff[1];
};
int test_funct(struct test_s *head, char *opt) {
        struct test_s *x = head;
        for (; x; x = x->next) {
                if (!*x->buff) { *x->buff = *opt; break; }
        }
        return x;
}
-----------------

.... and help me compile it into a variant with "normal/natural to architecture" pointers, and a variant with "fancy 16-bit" pointers?

Thenx in advance,

-R
PS: as before - I don't get mails from the list, pls CC responses to me.

Reply via email to