Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use struct instead of global variables in C? #15

Open
v1993 opened this issue May 4, 2019 · 0 comments
Open

Use struct instead of global variables in C? #15

v1993 opened this issue May 4, 2019 · 0 comments

Comments

@v1993
Copy link

v1993 commented May 4, 2019

I think about writting C++ wrapper around C version. However, it looks like C version use global variables and can have only one state.

I suggest making it in pseudo-OOP way, like

struct micromod_obj {
	signed char *module_data;
	…
}

long micromod_initialise_obj( struct micromod_obj obj, signed char *data, long sampling_rate );

and so on. You can keep compatiblity by declaring static struct micromod_obj micromod_instance; and making exsiting functions just wrappers around it, like:

long micromod_initialise( signed char *data, long sampling_rate ) {
	return micromod_initialise_obj( micromod_instance, data, sampling_rate );
}

What do you think? I'll try to do it myself meanwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant