cbmbasic
cbmbasic copied to clipboard
multiple definition of `RAM'
Trying to build on a stock Fedora 32 system (x86_64) gives me the following error:
[tdknox@fedoravm cbmbasic]$ make
cc -Wall -O3 -c -o cbmbasic.o cbmbasic.c
cbmbasic.c: In function ‘main’:
cbmbasic.c:1201:17: warning: variable ‘llvm_cbe_tmp1038410385_2e_lobit’ set but not used [-Wunused-but-set-variable]
1201 | unsigned char llvm_cbe_tmp1038410385_2e_lobit;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cbmbasic.c:1200:17: warning: variable ‘llvm_cbe_tmp1038210383’ set but not used [-Wunused-but-set-variable]
1200 | unsigned char llvm_cbe_tmp1038210383;
| ^~~~~~~~~~~~~~~~~~~~~~
cbmbasic.c:195:18: warning: variable ‘llvm_cbe_tmp1845’ set but not used [-Wunused-but-set-variable]
195 | unsigned char *llvm_cbe_tmp1845;
| ^~~~~~~~~~~~~~~~
cbmbasic.c:194:18: warning: variable ‘ltmp_2_1’ set but not used [-Wunused-but-set-variable]
194 | unsigned char *ltmp_2_1;
| ^~~~~~~~
cbmbasic.c:193:18: warning: variable ‘ltmp_1_1’ set but not used [-Wunused-but-set-variable]
193 | unsigned char *ltmp_1_1;
| ^~~~~~~~
cbmbasic.c:192:18: warning: variable ‘ltmp_0_1’ set but not used [-Wunused-but-set-variable]
192 | unsigned char *ltmp_0_1;
| ^~~~~~~~
cc -Wall -O3 -c -o runtime.o runtime.c
runtime.c: In function ‘OPEN’:
runtime.c:290:45: warning: pointer targets in passing argument 1 of ‘fopen’ differ in signedness [-Wpointer-sign]
290 | kernal_files[kernal_lfn] = fopen(RAM+kernal_filename, mode);
| ~~~^~~~~~~~~~~~~~~~
| |
| unsigned char *
In file included from runtime.c:30:
/usr/include/stdio.h:246:44: note: expected ‘const char * restrict’ but argument is of type ‘unsigned char *’
246 | extern FILE *fopen (const char *__restrict __filename,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
runtime.c: In function ‘LOAD’:
runtime.c:552:17: warning: variable ‘savedbyte’ set but not used [-Wunused-but-set-variable]
552 | unsigned char savedbyte;
| ^~~~~~~~~
runtime.c: In function ‘SAVE’:
runtime.c:695:17: warning: variable ‘savedbyte’ set but not used [-Wunused-but-set-variable]
695 | unsigned char savedbyte;
| ^~~~~~~~~
cc -Wall -O3 -c -o plugin.o plugin.c
plugin.c: In function ‘plugin_gone’:
plugin.c:242:18: warning: variable ‘b’ set but not used [-Wunused-but-set-variable]
242 | unsigned char b;
| ^
cc -Wall -O3 -c -o console.o console.c
cc -o cbmbasic cbmbasic.o runtime.o plugin.o console.o
/usr/bin/ld: runtime.o:(.bss+0x120): multiple definition of `RAM'; cbmbasic.o:(.bss+0x20): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:10: cbmbasic] Error 1
I am getting the exact same thing when trying to compile on Manjaro
I guess this is related to GCC 10. I'm on GCC 9 and don't get that error, however if I set -fno-common option I get the same error. You can read about this here: https://gcc.gnu.org/gcc-10/porting_to.html (Default to -fno-common)
You can either try fixing the source code by setting RAM to extern in all but one c file, or you can try in the makefile to add -fcommon to CFLAGS
https://github.com/mist64/cbmbasic/blob/89093eba090d6e1c2d2b6e1cb1616dba0ce9c7f6/runtime.c#L47 this should be extern i think. Yep, just tried this now and it works.