0

I'm getting the error:

    left_hand:3:20: error: expected ']' before ';' token
     #define HAND_ROWS 5;
                        ^

on this code:

    #include <Keyboard.h>

    #define HAND_ROWS 5;
    #define HAND_COLS 6;
    #define ROW_PINS {9, 8, 7, 6, 5};
    #define COL_PINS {10, 16, 14, 15, 18, 19};
    #define LOOP_SPEED = 10;

    const char keymap[HAND_ROWS][HAND_COLS] = {{0xB1, '1', '2', '3', '4', '5'}, 
                                               {0xB3, 0x81, 'q', 'w', 'e', 'r'}, 
                                               {'6', 0x80, 'a', 's', 'd', 'f'}, 
                                               {'7', 'z', 'x', 'c', 'v', 'b'}, 
                                               {'h', 'j', 0x82, ' ', 'k', 'l'}};
    boolean pressedKeys;
    int keymapIndex;

help, please? This makes no sense to me... If I try to use Keyboard.LEFT_SHIFT and equivalent constants for the hex-codes in the keymap, they tell me 'expected unqualified-id before numerical constant' What does this even mean? I'm so lost...

1
  • 1
    There's no semicolon needed on a #define. Commented Dec 6, 2019 at 0:15

1 Answer 1

1

You mustn't terminate a #define with a ;. Semicolons are for C and C++ statements. #define is a preprocessor statement.

#define creates a literal string replacement, so when you use it you end up with:

const char keymap[5;][6;] = {...

which is, of course, wrong.

4
  • Thank you for catching my beginner mistake! Commented Dec 5, 2019 at 23:30
  • It's no beginner mistake... I have done it myself from time to time... the fingers go on automatic... Commented Dec 5, 2019 at 23:31
  • Guess that's the fate of Java programmers who move to C, or at least that's the case for me. Commented Dec 6, 2019 at 0:17
  • @LowellCamp Or the fate of people that jump between three or four programming languages at once - and do their programming in the wee small hours of the morning ;) Commented Dec 6, 2019 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.