Explicitly use C11 dialect #1

Merged
merged 2 commits into from Jul 4, 2016

Projects

None yet

2 participants

@insom
Contributor
insom commented Jul 2, 2016

Hi,

Thanks for creating this project. On Ubuntu Xenial with the arm-none-eabi-gcc package, the supplied makefile gives these errors:

src/main.c: In function 'main':
src/main.c:21:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
         for (uint16_t i = 0; i != 0xffff; i++) { }
         ^
src/main.c:21:9: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
src/main.c:24:23: error: redefinition of 'i'
         for (uint16_t i = 0; i != 0xffff; i++) { }
                       ^

Adding -std=c11 as the error suggests returns everything to working order. Just thought this might save some future person a bad 'out of box' experience.

@kcuzner
Owner
kcuzner commented Jul 2, 2016 edited

It might be better to use C99, actually. C11 is so new that I don't think its common enough in older versions of GCC to be used yet. Not everyone uses the most up to date GCC. I read somewhere that not even all of C99 has been implemented in open source compilers.

Do you want to change it to C99 or did you have a specific reason for C11 over C99?

Aaron Brady C99 is enough f6808e2
@insom
Contributor
insom commented Jul 4, 2016

@kcuzner GOOD point. I've updated this to C99 - that's sufficient to allow declaring variables inside for loops.

@kcuzner kcuzner merged commit 5d54dc7 into kcuzner:master Jul 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment