Details
Description
In my program's i have arrays of data, with enums describing the meaning like this:
typedef enum {
ITEM_0 = 0,
ITEM_1,
ITEM_2,
ITEMS_ARRAY_SIZE,
}ITEMS_ENUM;
uint32_t myItems[ITEMS_ARRAY_SIZE];
Then in my code I can access a place in the array like this:
myItems[ITEM_0] = 34;
The debugger doesn't understand the indexes of the array are coming from an enum, and therefore displays the value of the array like this:
myItems value type [0] 34 uint32_t
It would be nice if the debugger would show it like this:
myItems value type [ITEM_0] 34 uint32_t
For this to work, the Qt debugger should first see the size of the array is an element of an enum, and then assume the rest of the values of the enum are used to name the indexes of the array. Of course this doesn't work for every situation, so we also need a way to switch back from enum display to 0,1,2,3... display.
I'm looking for a solution that works with standard C enums and arrays, as I'm using Qt to run and debug legacy C programs. Therefore I can't (easily) use C++ constructions to achieve this.
My versions:
Qt Creator 12.0.1
Based on Qt 6.6.1 (GCC 13.2.1 20230801, x86_64)
$ uname -a
Linux cedric 6.6.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 14 Dec 2023 03:45:42 +0000 x86_64 GNU/Linux
See these mockups:
[dbfe17f2-9b84-4a11-8a30-e784bb315e15-image.png|https://ddgobkiprc33d.cloudfront.net/6aee8a6b-c68d-43cc-86e2-167583b09b0b.png|https://ddgobkiprc33d.cloudfront.net/6aee8a6b-c68d-43cc-86e2-167583b09b0b.png]
[708a7f76-c0e8-4026-b777-4a8844b024b6-image.png]|https://ddgobkiprc33d.cloudfront.net/c41c142a-d5dd-45e2-9866-350d2a1145f4.png|https://ddgobkiprc33d.cloudfront.net/c41c142a-d5dd-45e2-9866-350d2a1145f4.png]
mainwindow.cpp (the other project files are default)
#include "mainwindow.h" #include "ui_mainwindow.h" typedef enum { ITEM_0 = 0, ITEM_1, ITEM_2, ITEMS_ARRAY_SIZE, }ITEMS_ENUM; uint32_t myItems[ITEMS_ARRAY_SIZE]; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); myItems[ITEM_0] = 34; myItems[ITEM_1] = 16; myItems[ITEM_2] = 45; } MainWindow::~MainWindow() { delete ui; }