rainerf / ricodebug

ricodebug is a debugger featuring data visualization, similar to DDD
12 stars 9 forks source link

Datagraph Array[Variable] #6

Closed bernschab closed 12 years ago

bernschab commented 12 years ago

Variablen als Längenangabe bei Arrays werden nicht sinnvoll interpretiert -> keine Darstellung im Graph möglich.


#include <iostream>
#include <cmath>

using namespace std;

int main () {

    size_t MAX = 100;
    int sinArray[MAX];
    int yxArray[MAX];

    for (size_t i=0; i<MAX; i++){
        yxArray[i] = i;
    }

    for (size_t i=0; i<MAX; i++){
        sinArray[i] = 100*sin((1.0*i)/10);
    }

    for (size_t i=0; i<MAX; i++){
        cout << i << ": " << sinArray[i] << endl;
    }
    return 0;
}
rainerf commented 12 years ago
size_t MAX = 100;
int sinArray[MAX];

This is not allowed in ISO C++:

main.cpp:9:21: warning: ISO C++ forbids variable length array ‘sinArray’ [-Wvla]
main.cpp:10:20: warning: ISO C++ forbids variable length array ‘yxArray’ [-Wvla]

DDD seems to handle this by interpreting both arrays as pointers -- this could be a solution worth investigating.