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

cast-align issues in tn_fmem_create #7

Open
travisgriggs opened this issue Nov 28, 2017 · 1 comment
Open

cast-align issues in tn_fmem_create #7

travisgriggs opened this issue Nov 28, 2017 · 1 comment

Comments

@travisgriggs
Copy link
Contributor

I'm trying to use tneo in my samd21 (m0+) project. Since I have my own build engine based on python, I'm doing the "build manually" route. One of the options I compile with is -Wcast-align. However, doing so is producing the following error:

/Users/travisg/Projects/twig_lora_tneo/TNEO/core/tn_fmem.c: In function 'tn_fmem_create':
/Users/travisg/Projects/twig_lora_tneo/TNEO/core/tn_fmem.c:333:20: error: cast increases required alignment of target type [-Werror=cast-align]
          p_tmp   = (void **)p_block;

I'm not sure what the best way to get around this is. I can remove that option, but once upon a time, I had convinced myself that was a good thing to check for.

@ghost
Copy link

ghost commented Oct 24, 2018

I think as both start_address and block_size are aligned values, you are safe to use void* instead of unsigned char* here, so the whole block would be:

      void **p_tmp;
      void *p_block;
      int i;

      p_tmp    = (void **)fmem->start_addr;
      p_block = (unsigned char*)fmem->start_addr + fmem->block_size;
      .... loop comes here 

But then of course you'll get "pointer of type ‘void *’ used in arithmetic",
i've fixed it in this way:

p_block = (unsigned char *)p_block + fmem->block_size;

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