library, struct, typdef and initialization

Hi Forum :slight_smile:

i am writing a library ( the idea was to extract some code i will use in the next and some other projects too...)
the functionality is finished in the current project - so it is just the task to extract it into a external library.

I have read the LibraryTutorial as a starting point. (Its really cool! easy understanding!)

So in the original project the function accessed lots of global variables. So my Idea was to pack them in a struct.
But hm - not so easy^^
i have tried with something like:
this definition is written in the header file of the lib.

struct someValues
	{
		word wLevel_Min		= 0;
		word wLevel_Max		= 65535;
		word wStep_Up		= 1;
		word wStep_Down		= 1;
		word wDelay_Up		= 1;
		word wDelay_Down	= 1;
	};
	
	typedef struct someValues svXXX;

if i try to compile my test / example sketch he throws some errors:

test.h:38: error: ISO C++ forbids initialization of member 'wLevel_Min'
test.h:38: error: making 'wLevel_Min' static
test.h:38: error: ISO C++ forbids in-class initialization of non-const static member 'wLevel_Min'

if i am interpreting this right - i am not able to initialize my struct to standard values?

in the example sketch i have something like:

/**
  * Values for a Testing Thing
  **/
const svXXX someNiceNameing;
	someNiceNameing.wLevel_Min	=     0;
	someNiceNameing.wLevel_Max	= 65535;
	someNiceNameing.wStep_Up		=  1;
	someNiceNameing.wStep_Down	=  1;
	someNiceNameing.wDelay_Up	=  5;
	someNiceNameing.wDelay_Down	= 15;

is this the right idea or iam on the absolut wrong way with the hole struct? :~

sunny greatings
stefan

Ok found out some things:

initialization is not allowed.

initialization in test sketch looks now this way:

/**
  * Values for a Testing Thing
  **/
const svXXX someNiceNameing;

void setup()
{
	//other stuff...

	someNiceNameing.wLevel_Min	=     0;
	someNiceNameing.wLevel_Max	= 65535;
	someNiceNameing.wStep_Up		=  1;
	someNiceNameing.wStep_Down	=  1;
	someNiceNameing.wDelay_Up	=  5;
	someNiceNameing.wDelay_Down	= 15;

	//other stuff...
}

this looks all good
:slight_smile:
sunny greetings
stefan

EDIT:
OK - I have just figured out a Problem:
with the way I do the Initialization of 'someNiceNameing' it is to late :slight_smile:
just after declared the variable i 'create' something like:

/**
  * Values for a Testing Thing
  **/
 svXXX someNiceNameing;

ALib myalib(someNiceNameing);
//...

so the things i initialize the someNiceNameing with dont gets into my ALib because it just gets the original state after svXXX in Empty (undefined) state.

so how can i make this the way i want? with pointers? or is there a other possibility to get it working?
i just need the someNiceNameing once to give the values to myalib.... (as const)