Giter Site home page Giter Site logo

GCC 12 build issue: `error: loop variable ‘keyType’ creates a copy from type ‘const std::pair<const KeyType, int>’ [-Werror=range-loop-construct]` about tourbox_neo_linux_driver HOT 6 CLOSED

celticsamurai avatar celticsamurai commented on July 23, 2024
GCC 12 build issue: `error: loop variable ‘keyType’ creates a copy from type ‘const std::pair’ [-Werror=range-loop-construct]`

from tourbox_neo_linux_driver.

Comments (6)

raleighlittles avatar raleighlittles commented on July 23, 2024

Hmm, I just tested this today and I wasn't able to reproduce this error, it builds fine for me.

image

Can you check what version of GCC and what version of CMake you're running? Run gcc --version and cmake --version.

I'm using gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 and cmake version 3.22.1

@celticsamurai

from tourbox_neo_linux_driver.

celticsamurai avatar celticsamurai commented on July 23, 2024

gcc (GCC) 12.2.0
cmake version 3.24.2
I'm using Arch Linux. Could that be making the difference?

from tourbox_neo_linux_driver.

raleighlittles avatar raleighlittles commented on July 23, 2024

Figured it out. Your newer version of GCC added a new warning that wasn't on GCC version 11. I've since updated the code to fix it.

from tourbox_neo_linux_driver.

celticsamurai avatar celticsamurai commented on July 23, 2024

Well, looks like since I now have GCC 13, it's giving me this error.

[ 50%] Building CXX object CMakeFiles/TourBox_Linux_Driver.dir/main.cpp.o
/home/wayne/Tourbox_Neo_Linux_Driver/cpp/main.cpp: In function ‘int main(int, char**)’:
/home/wayne/Tourbox_Neo_Linux_Driver/cpp/main.cpp:74:16: error: ‘uint8_t’ was not declared in this scope
74 | std::array<uint8_t, 1> readBuffer;
| ^~~~~~~
/home/wayne/Tourbox_Neo_Linux_Driver/cpp/main.cpp:24:1: note: ‘uint8_t’ is defined in header ‘’; did you forget to ‘#include ’?
23 | #include "uinput_helper.hpp"
+++ |+#include
24 |
/home/wayne/Tourbox_Neo_Linux_Driver/cpp/main.cpp:74:26: error: template argument 1 is invalid
74 | std::array<uint8_t, 1> readBuffer;
| ^
/home/wayne/Tourbox_Neo_Linux_Driver/cpp/main.cpp:89:71: error: request for member ‘begin’ in ‘readBuffer’, which is of non-class type ‘int’
89 | ssize_t bytesRead = read(serialPortFileDescriptor, readBuffer.begin(), 1);
| ^~~~~
/home/wayne/Tourbox_Neo_Linux_Driver/cpp/main.cpp:100:85: error: invalid types ‘int[int]’ for array subscript
100 | std::cout << std::hex << std::setfill('0') << std::setw(2) << readBuffer[0] << " " << readBuffer[1] << std::endl;
| ^
/home/wayne/Tourbox_Neo_Linux_Driver/cpp/main.cpp:100:109: error: invalid types ‘int[int]’ for array subscript
100 | std::cout << std::hex << std::setfill('0') << std::setw(2) << readBuffer[0] << " " << readBuffer[1] << std::endl;
| ^
/home/wayne/Tourbox_Neo_Linux_Driver/cpp/main.cpp:102:31: error: invalid types ‘int[int]’ for array subscript
102 | switch (readBuffer[0])
| ^
make[2]: *** [CMakeFiles/TourBox_Linux_Driver.dir/build.make:76: CMakeFiles/TourBox_Linux_Driver.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/TourBox_Linux_Driver.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

from tourbox_neo_linux_driver.

raleighlittles avatar raleighlittles commented on July 23, 2024

@celticsamurai I can't reproduce this error, I'm running the latest Ubuntu version which still has GCC 11.4 installed.

It looks like the error is complaining about a missing include to stdint.h since that's where the uint8_t type is declared. I've added it in the latest commit: c797349

from tourbox_neo_linux_driver.

celticsamurai avatar celticsamurai commented on July 23, 2024

Okay so after updating, I was able to compile it again.

from tourbox_neo_linux_driver.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.