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

Build error on windows. #3

Open
antithing opened this issue Apr 2, 2017 · 1 comment
Open

Build error on windows. #3

antithing opened this issue Apr 2, 2017 · 1 comment

Comments

@antithing
Copy link

Hi, i am trying to compile on widows, visual studio 2015, and i am getting errors on all these lines:

EEKF_DECL_MAT_DYN

Error C2133 'Ct_elements': unknown size eekf D:\eekf-master\src\eekf.c 123

What am I doing wrong here?

Thank you for making this code available!

@dr-duplo
Copy link
Owner

dr-duplo commented Apr 3, 2017

Hi, thank you for reporting the issue. I only used GNU based tools with this code, which support parameter dependent array sizes (came in with C99, support for C++ by GNU). But there's an alternative: alloca(). You could do the following:

  1. Replace the definition of with EEKF_DECL_MAT_DYN
    #define EEKF_DECL_MAT_DYN(name, rows, cols)\ eekf_value name##_elements[(rows)*(cols)];\ eekf_mat name = {name##_elements, (rows), (cols)};
    with
    #define EEKF_DECL_MAT_DYN(name, rows, cols)\ eekf_value name##_elements = (eekf_value *) _alloca((rows)*(cols)*sizeof(eekf_value));\ eekf_mat name = {name##_elements, (rows), (cols)}

  2. Don't forget the include. probably <malloc.h>.

  3. Make a compiler dependent code switch around it.

  4. I would appreciate your pull request.

PS: _alloca allocates memory on the current stack. there's no need to free it as it will be thrown away when the function returns.

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

2 participants