Declaring and initialising constant nested arrays
I'm having a little bit of bother trying to understand the way to declare global variables (infact I'm not sure if this is really the best way to go... so alternative suggestions are also very welcome)
My current project is to try to develop a GUI button and am writing it using a combination of C and openGL. I would like to have two arrays - one which holds the coordinates of the button and one which holds the colours for each vertex.
I created a header and source file for the 'button code'. I began by creating a struct to hold various data associated with the button including a label coords[8][2] and colours[8][3]. And also in the header I declared a function which would initialise the struct.
The issue I am struggling with is where to put the data itself!
If I declare the core data for say the button coordinates in the button.h file, there is no problem, but as soon as I also try to initialise the nested array... eg.
buttonData[8][2] = {[0,0], [1,0].... etc}
I get compiler errors. I get compiler (syntax) errors if it is a 'flat' array too, such as
buttonData[16] = {0,0,1,0.... etc}
In the end, the only solution I could find with my current understanding is to declare and initialise 1 dimensional arrays in the main.c file, above the main() function and use the 'extern' declaration in my button.h file. This works fine, but is not quite the way I wanted to go as I was hoping to have everything in the button.h and button.c files
Am I thinking about this all wrong?
Thanks in advance for any help with this