Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Warnings in library code [old code]
Forum Updated to NodeBB v4.3 + New Features

Warnings in library code [old code]

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 494 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ODБOïO Offline
    ODБOïO Offline
    ODБOï
    wrote on last edited by ODБOï
    #1

    I use this VNC client .
    In one of its sources, this code :

    void usekey(register unsigned long *from)
    {
        register unsigned long *to, *endp;
    
        to = KnL, endp = &KnL[32];
        while( to < endp ) *to++ = *from++;
        return;
    }
    

    error : ISO C++17 does not allow 'register' storage class specifier
    warning : possible misuse of comma operator
    to = KnL, endp = &KnL[32];

    I knew it's possible to declare several variables in one line :

    unsigned long *to, *endp;
    

    but never saw assignment (is this possible because the declaration is done in one line also ? ) :

    to = KnL, endp = &KnL[32]; 
    

    should i correct this to make QtCreator happy ?

    How to deal with the register ?

    What about the old SIGNAL/SLOT syntax, should i replace with the new one ?

    jsulmJ 1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      I would most likely compile this as a separate library with its own compilation rules and settings. I would also find out under which version of c++ it was written and use that for compilation. Unless I completely understood all the reasons for the code it might introduce bugs.

      I am a little wary of that code and its lack of pointer verification, but I don't know what the rest of the code looks like.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      2
      • ODБOïO ODБOï

        I use this VNC client .
        In one of its sources, this code :

        void usekey(register unsigned long *from)
        {
            register unsigned long *to, *endp;
        
            to = KnL, endp = &KnL[32];
            while( to < endp ) *to++ = *from++;
            return;
        }
        

        error : ISO C++17 does not allow 'register' storage class specifier
        warning : possible misuse of comma operator
        to = KnL, endp = &KnL[32];

        I knew it's possible to declare several variables in one line :

        unsigned long *to, *endp;
        

        but never saw assignment (is this possible because the declaration is done in one line also ? ) :

        to = KnL, endp = &KnL[32]; 
        

        should i correct this to make QtCreator happy ?

        How to deal with the register ?

        What about the old SIGNAL/SLOT syntax, should i replace with the new one ?

        jsulmJ Online
        jsulmJ Online
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #3

        @LeLev Looks like "register" keyword was removed in C++17: https://stackoverflow.com/questions/20618008/replacement-for-deprecated-register-keyword-c-11
        This code will not compile with C++17 compiler without modifications.
        "should i correct this to make QtCreator happy ?" - the "problem" is not QtCreator but the C++ compiler you're using.
        Change to

        void usekey(register unsigned long *from)
        {
            unsigned long *to, *endp;
        
            to = KnL;
            endp = &KnL[32];
            while( to < endp ) *to++ = *from++;
            return;
        }
        

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        4

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved