expected primary-expression before '[' token

Hallo,
Ich baue mir grade eine Library für Ein touchdisplay zusammen, womit ich auf dem display abfragen kann, ob der gedrückte Punkt in einem zuvor definierten bereich liegt.
Leider kommt es dabei zu nür mich unerklährlichen Fehlern:

C:\Users\Flo\AppData\Local\Temp\arduino_build_130905\sketch\touchArea.cpp: In member function 'int touchArea::addTouchArea(long int, long int, long int, long int, char)':

touchArea.cpp:18:29: error: expected primary-expression before '[' token

         while (touchAreaType[counter].used == false && counter < maxTouchArea) counter++;

                             ^

touchArea.cpp:21:30: error: expected unqualified-id before '[' token

                 touchAreaType[counter].used = true;

                              ^

touchArea.cpp:22:30: error: expected unqualified-id before '[' token

                 touchAreaType[counter].Id = Id;

                              ^

touchArea.cpp:23:30: error: expected unqualified-id before '[' token

                 touchAreaType[counter].x1 = x1;

                              ^

touchArea.cpp:24:30: error: expected unqualified-id before '[' token

                 touchAreaType[counter].y1 = y1;

                              ^

touchArea.cpp:25:30: error: expected unqualified-id before '[' token

                 touchAreaType[counter].x2 = x2;

                              ^

touchArea.cpp:26:30: error: expected unqualified-id before '[' token

                 touchAreaType[counter].y2 = y2;

                              ^

C:\Users\Flo\AppData\Local\Temp\arduino_build_130905\sketch\touchArea.cpp: In member function 'bool touchArea::removeTouchArea(char)':

touchArea.cpp:33:28: error: expected primary-expression before '[' token

         while(touchAreaType[counter].Id != Id && counter < maxTouchArea) counter++;

                            ^

touchArea.cpp:34:25: error: expected primary-expression before '[' token

         if(touchAreaType[counter].Id == Id) touchAreaType[counter].used = false; return 1;

                         ^

touchArea.cpp:34:58: error: expected unqualified-id before '[' token

         if(touchAreaType[counter].Id == Id) touchAreaType[counter].used = false; return 1;

                                                          ^

touchArea.cpp:35:9: error: 'else' without a previous 'if'

         else return 0;

         ^

C:\Users\Flo\AppData\Local\Temp\arduino_build_130905\sketch\touchArea.cpp: In member function 'bool touchArea::removeTouchArea(int)':

touchArea.cpp:39:22: error: expected unqualified-id before '[' token

         touchAreaType[Id].used = false;

                      ^

C:\Users\Flo\AppData\Local\Temp\arduino_build_130905\sketch\touchArea.cpp: In member function 'char touchArea::gettouchArea(long int, long int)':

touchArea.cpp:46:43: error: expected primary-expression before '[' token

                 if(isBetween(touchAreaType[counter].x1, x, touchAreaType[counter].x2) && isBetween(touchAreaType[counter].y1, y, touchAreaType[counter].y2)) {

                                           ^

touchArea.cpp:46:73: error: expected primary-expression before '[' token

                 if(isBetween(touchAreaType[counter].x1, x, touchAreaType[counter].x2) && isBetween(touchAreaType[counter].y1, y, touchAreaType[counter].y2)) {

                                                                         ^

touchArea.cpp:46:113: error: expected primary-expression before '[' token

                 if(isBetween(touchAreaType[counter].x1, x, touchAreaType[counter].x2) && isBetween(touchAreaType[counter].y1, y, touchAreaType[counter].y2)) {

                                                                                                                 ^

touchArea.cpp:46:143: error: expected primary-expression before '[' token

                 if(isBetween(touchAreaType[counter].x1, x, touchAreaType[counter].x2) && isBetween(touchAreaType[counter].y1, y, touchAreaType[counter].y2)) {

                                                                                                                                               ^

touchArea.cpp:47:45: error: expected primary-expression before '[' token

                         return touchAreaType[counter].Id;

Der Code befindet sich im Anhang
Viele Grüße,
Flo

touchArea.cpp (1.89 KB)

touchArea.h (548 Bytes)

Fehler.txt (18.9 KB)

'touchAreaType' ist kein Array. Aus deinem Code:

typedef struct
{
        long x1, y1, x2, y2;
        char Id;
        bool used;
}
touchAreaType;

Du wolltest wahrscheinlich 'TouchAreas' verwenden.

LightuC:
'touchAreaType' ist kein Array. Aus deinem Code:

Du wolltest wahrscheinlich 'TouchAreas' verwenden.

UPS

GLS :slight_smile:

Netter Fehler!