rpitx
rpitx copied to clipboard
Compile Problem: inline variable declarations problem
During compile pifmrds related C files causes problem. When I define these i and j variables outside of for loop line, problem solved, and compiled. Runs successfully now.
c++ -std=c++11 -Wall -g -O2 -Wno-unused-variable -o ../pisstv sstv/pisstv.cpp li brpitx/src/librpitx.a -lm -lrt -lpthread
c++ -std=c++11 -Wall -g -O2 -Wno-unused-variable -o ../piopera opera/opera.cpp l ibrpitx/src/librpitx.a -lm -lrt -lpthread
c++ -std=c++11 -Wall -g -O2 -Wno-unused-variable -o ../pifsq fsq/pifsq.cpp librp itx/src/librpitx.a -lm -lrt -lpthread
c++ -std=c++11 -Wall -g -O2 -Wno-unused-variable -o ../pichirp chirp/chirp.cpp l ibrpitx/src/librpitx.a -lm -lrt -lpthread
c++ -std=c++11 -Wall -g -O2 -Wno-unused-variable -o ../sendiq sendiq.cpp librpit x/src/librpitx.a -lm -lrt -lpthread
c++ -std=c++11 -Wall -g -O2 -Wno-unused-variable -o ../tune tune.cpp librpitx/sr c/librpitx.a -lm -lrt -lpthread
c++ -std=c++11 -Wall -g -O2 -Wno-unused-variable -o ../freedv freedv/freedv.cpp librpitx/src/librpitx.a -lm -lrt -lpthread
cc -Wall -g -O2 -Wno-unused-variable -c -o dvb/dvbsenco8.o dvb/dvbsenco8.s
cc -Wall -g -O2 -Wno-unused-variable -c -o dvb/dvbs2arm_1v30.o dvb/dvbs2arm_1v30. s
cc -Wall -g -O2 -Wno-unused-variable -c -o dvb/fec100.o dvb/fec100.c
c++ -std=c++11 -Wall -g -O2 -Wno-unused-variable -o ../dvbrf dvb/dvbrf.cpp dvb/dv bsenco8.o dvb/fec100.o dvb/dvbs2arm_1v30.o librpitx/src/librpitx.a -lm -lrt -lpth read
c++ -std=c++11 -Wall -g -O2 -Wno-unused-variable -o ../pocsag pocsag/pocsag.cpp l ibrpitx/src/librpitx.a -lm -lrt -lpthread
c++ -std=c++11 -Wall -g -O2 -Wno-unused-variable -o ../spectrumpaint spectrumpain t/spectrum.cpp librpitx/src/librpitx.a -lm -lrt -lpthread
cc -Wall -g -O2 -Wno-unused-variable -c -o pifmrds/rds.o pifmrds/rds.c
pifmrds/rds.c: In function ‘crc’:
pifmrds/rds.c:64:5: error: ‘for’ loop initial declarations are only allowed in C9 9 or C11 mode
for(int j=0; j<BLOCK_SIZE; j++) {
^
pifmrds/rds.c:64:5: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
pifmrds/rds.c: In function ‘get_rds_group’:
pifmrds/rds.c:148:5: error: ‘for’ loop initial declarations are only allowed in C 99 or C11 mode
for(int i=0; i<GROUP_LENGTH; i++) {
^
pifmrds/rds.c:151:9: error: ‘for’ loop initial declarations are only allowed in C 99 or C11 mode
for(int j=0; j<BLOCK_SIZE; j++) {
^
pifmrds/rds.c:155:17: error: redefinition of ‘j’
for(int j=0; j<POLY_DEG; j++) {
^
pifmrds/rds.c:151:17: note: previous definition of ‘j’ was here
for(int j=0; j<BLOCK_SIZE; j++) {
^
pifmrds/rds.c:155:9: error: ‘for’ loop initial declarations are only allowed in C 99 or C11 mode
for(int j=0; j<POLY_DEG; j++) {
^
pifmrds/rds.c: In function ‘get_rds_samples’:
pifmrds/rds.c:182:5: error: ‘for’ loop initial declarations are only allowed in C 99 or C11 mode
for(int i=0; i<count; i++) {
^
pifmrds/rds.c:199:13: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for(int j=0; j<FILTER_SIZE; j++) {
^
pifmrds/rds.c: In function ‘set_rds_rt’:
pifmrds/rds.c:241:5: error: ‘for’ loop initial declarations are only allowed in C 99 or C11 mode
for(int i=0; i<64; i++) {
^
pifmrds/rds.c: In function ‘set_rds_ps’:
pifmrds/rds.c:248:5: error: ‘for’ loop initial declarations are only allowed in C 99 or C11 mode
for(int i=0; i<8; i++) {
^
Makefile:49: recipe for target '../pifmrds' failed
make: *** [../pifmrds] Error 1
I had this issue. I saw another post somewhere which fixed it by declaring the index before the for loop, but I cannot find it now. This is more recent anyway. I didn't want to fix every for loop, so I found the place in the rpitx/src/Makefile that caused the problem.
in rpitx/src: diff Makefile old/Makefile.2020-04-20.13-24 3c3 < CFLAGS = -std=gnu11 -Wall -g -O2 -Wno-unused-variable
CFLAGS = -Wall -g -O2 -Wno-unused-variable
I added the -std=gnu11 to the CFLAGS in the rpitx/src/Makefile
I originally tried -std=c11 or -std=c99 which fixed this error but it introduced another error: error: ‘struct tm’ has no member named ‘tm_gmtoff’
I wonder why everyone hasn't experienced the for loop problem. My version of c and libraries: $ cc --version cc (Raspbian 4.9.2-10+deb8u2) 4.9.2 $ ldd --version ldd (Debian GLIBC 2.19-18+deb8u10) 2.19 $ /lib/arm-linux-gnueabihf/libc.so.6 GNU C Library (Debian GLIBC 2.19-18+deb8u10) stable release version 2.19, by Roland McGrath et al. 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. Compiled by GNU CC version 4.8.4. Compiled on a Linux 3.16.7 system on 2017-06-19.
I hope this helps at least one person. I am new to radio after buying #034 Kit from hackerboxes.com. This is not in the kit but I ran into it and had a Raspberry Pi around. by the way, happy belated Pi day. I found that I am not very good at searching the internet, so maybe everyone already knows this.
I also put this issue onto groups.io https://groups.io/g/rpitx/message/317