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

Provide -std=c99 to allow compilation with older toolchains #773

Closed
stanislavvv opened this issue Apr 17, 2017 · 4 comments
Closed

Provide -std=c99 to allow compilation with older toolchains #773

stanislavvv opened this issue Apr 17, 2017 · 4 comments

Comments

@stanislavvv
Copy link

commit 383fafc (current master)
make give me:

...
  CC      crs_common_all.c
  CC      usart_common_v2.c
  CC      i2c_common_v2.c
../common/i2c_common_v2.c: In function 'i2c_transfer7':
../common/i2c_common_v2.c:431:3: error: 'for' loop initial declarations are only allowed in C99 mode
   for (size_t i = 0; i < rn; i++) {
   ^
../common/i2c_common_v2.c:431:3: note: use option -std=c99 or -std=gnu99 to compile your code
../../Makefile.include:44: recipe for target 'i2c_common_v2.o' failed
make[1]: *** [i2c_common_v2.o] Error 1
Makefile:63: recipe for target 'lib/stm32/f0' failed
make: *** [lib/stm32/f0] Error 2

With CFLAGS="-std=gnu99" make all build fine, but i think it may be bug in makefile or documentation.

@karlp
Copy link
Member

karlp commented Apr 18, 2017

yes. I "broke" it recently by using c99 code. The codebase didn't have any -std= flag, so was getting toolchain defaults, and I've been on a gcc 5.x toolchain for a while now. (which defaults to c11 iirc)

It was reported here, but the "right" thing to do is add the -std=c99 flags to the library makefiles.

For your particular case, you can also just start using a newer toolchain :) Sorry about the inconvenience though, it was not intentional to break compiles on older toolchains.

@karlp karlp changed the title make does not build library with default makefile Provide -std=c99 to allow compilation with older toolchains Apr 18, 2017
@karlp karlp self-assigned this Apr 18, 2017
@katyo
Copy link

katyo commented Apr 21, 2017

I have same issue when using GCC ARM toolchain from GNU/Debian

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (4.9.2-10+14~bpo8+1) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@karlp
Copy link
Member

karlp commented Apr 21, 2017

And you have the same solution :)

karlp added a commit to karlp/libopencm3 that referenced this issue Apr 24, 2017
setting "STANDARD_FLAGS=-std=c11" or similar will let you try out
alternate compilation modes.

Fixes libopencm3#773
@karlp karlp mentioned this issue Apr 24, 2017
karlp added a commit to karlp/libopencm3 that referenced this issue May 1, 2017
setting "STANDARD_FLAGS=-std=c11" or similar will let you try out
alternate compilation modes.

Fixes libopencm3#773
karlp added a commit to karlp/libopencm3 that referenced this issue May 6, 2017
setting "STANDARD_FLAGS=-std=c11" or similar will let you try out
alternate compilation modes.

Fixes libopencm3#773
karlp added a commit to karlp/libopencm3 that referenced this issue May 8, 2017
setting "STANDARD_FLAGS=-std=c11" or similar will let you try out
alternate compilation modes.

Fixes libopencm3#773
@vdudouyt
Copy link

vdudouyt commented Jun 9, 2017

I confirm, karlp's solution is working fine for me. Eager to see that in upstream.

@karlp karlp closed this as completed in b860319 Aug 24, 2017
BOJIT pushed a commit to BOJIT/PlatformIO-libopencm3 that referenced this issue Jan 30, 2021
setting "STANDARD_FLAGS=-std=c11" or similar will let you try out
alternate compilation modes.

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

No branches or pull requests

4 participants