Skip to content

Special Interest Groups

Forums connected to various groups live here
2.0k Topics 12.5k Posts

Subcategories


  • QtonPi
    405 Topics
    2k Posts
    N

    Found it. For future viewers, on Debian-based systems the package one needs to install is waylandpp-dev. This will install all dev dependencies for Wayland.

  • Qt Contribution
    82 Topics
    508 Posts
    VRoninV

    @Paul-Breeuwsma said in Idea for not-null pointer type support in the Qt API:

    passing null would give undefined behaviour

    99.9999999% of the times passing null is segfault. QUndoGroup::addStack is a great example. Its an easy crash to debug

    I feel like the concept of "not null pointer" already exists in C++, it's called a reference. Qt already uses references as never-null-pointers internally in the D-Pointer architecture (e.g. QObject::QObject(QObjectPrivate &dd, QObject *parent) where the first argument is actually a pointer that is never null). It just turns out sometimes it's more confusing to use the reference than having an explicit pointer

  • Qt Medical

    13 Topics
    39 Posts
    aha_1980A

    @Pinho Yes that sounds reasonable to me.

  • Qt on BlackBerry and QNX
    103 Topics
    587 Posts
    cristian-adamC

    See https://www.reddit.com/r/QNX/comments/1gl76uy/qnx_everywhere_the_latest_qnx_is_free_now/

  • The forum for all discussions in C++ land.
    1k Topics
    8k Posts
    S

    It might work right now, but will not in the future.

    There is a new feature coming to C++26 (https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2795r3.html) which addresses a problem related to this. Currently if you do something like this

    void f() { const char password[] = "secret"; } void g() { char str[7]; std::cout << str << '\n'; } int main() { f(); g(); }

    it will most likely print secret. Both functions will use the same stack space and reuse the same memory. The proposal for C++26 is to handle uninitialized variables explicitly to avoid this problem.

    On the other hand this also means in your concrete case if some other function reuses the same stack space it will overwrite \x11\x01\x1E\xD0.

    Someone should check the following with the standard, but I believe there is a difference between

    char serialNumberCommand[] = "\x11\x01\x1E\xD0";

    and

    char *serialNumberCommand = "\x11\x01\x1E\xD0";

    I would expect the first version to copy the string into the serialNumberCommand array. In the latter case you are just holding a pointer to an existing string in static storage. This pointer can then be handed safely to QByteArray::fromRawData as QByteArray will not hold the pointer handed to it, but the thing it points to. The thing it points to should be permanent. (I am not sure it the C++ standard guarantees this, but it is the general implementation of C strings.)

    If you want something more fancy, there is not only constexpr but also constinit (since C++20). cppreference (https://en.cppreference.com/w/cpp/language/constinit) mentions that constinit declares a variable with static or thread storage duration. However, as the example on that page shows, you need to write static constinit inside a function. Just constinit alone will not do.

  • A forum for independent Developers and freelancers
    79 Topics
    622 Posts
    JonBJ

    @Sachin-Bhatt
    It's not a problem, you can ask whatever you wish. And sometimes you will get answers if it's not Qt. Just (a) you didn't get any! and (b) I think your question is so specific/detailed that you need/might be better in a specialist, dedicated forum for this one.

  • 2 Topics
    3 Posts
    N

    @ClaraMarieLueders I think you should describe it more specifically