Page 1 of 1

oofatfs problem with macro concat ##

Posted: Wed Jan 13, 2021 11:19 am
by ExXec
Hey there,
I am rebasing my port on the newest version of the upstream project and I am getting this error for lib/oofatfs/ffunicode.c and ff.c (after adjusting to the unicode.c rename):

Code: Select all

mkdir -p build/genhdr
Create build/genhdr/pins.h
GEN build/genhdr/mpversion.h
GEN build/genhdr/moduledefs.h
GEN build/genhdr/pybcdc.inf
GEN build/genhdr/pybcdc_inf.h
GEN build/genhdr/qstr.i.last
../../lib/oofatfs/ffunicode.c:262:28: error: pasting "uc" and "(" does not give a valid preprocessing token
     const WCHAR *p = CVTBL(uc, FF_CODE_PAGE);
                            ^
../../lib/oofatfs/ffunicode.c:34:22: note: in definition of macro 'MERGE2'
 #define MERGE2(a, b) a ## b
                      ^
../../lib/oofatfs/ffunicode.c:262:22: note: in expansion of macro 'CVTBL'
     const WCHAR *p = CVTBL(uc, FF_CODE_PAGE);
                      ^
../../lib/oofatfs/ffunicode.c:284:28: error: pasting "uc" and "(" does not give a valid preprocessing token
     const WCHAR *p = CVTBL(uc, FF_CODE_PAGE);
                            ^
../../lib/oofatfs/ffunicode.c:34:22: note: in definition of macro 'MERGE2'
 #define MERGE2(a, b) a ## b
                      ^
../../lib/oofatfs/ffunicode.c:284:22: note: in expansion of macro 'CVTBL'
     const WCHAR *p = CVTBL(uc, FF_CODE_PAGE);
                      ^
../../lib/oofatfs/ff.c:559:37: error: pasting "TBL_CT" and "(" does not give a valid preprocessing token
 static const BYTE ExCvt[] = MKCVTBL(TBL_CT, FF_CODE_PAGE);
                                     ^
../../lib/oofatfs/ff.c:422:26: note: in definition of macro 'MERGE_2STR'
 #define MERGE_2STR(a, b) a ## b
                          ^
../../lib/oofatfs/ff.c:559:29: note: in expansion of macro 'MKCVTBL'
 static const BYTE ExCvt[] = MKCVTBL(TBL_CT, FF_CODE_PAGE);
                             ^
../../py/mkrules.mk:88: recipe for target 'build/genhdr/qstr.i.last' failed
make: *** [build/genhdr/qstr.i.last] Error 1
It seem the preprocessor cannot process the tokens

Code: Select all

#define MERGE_2STR(a, b) a ## b
#define MKCVTBL(hd, cp) MERGE_2STR(hd, cp)
properly.
If I replace them like this it compiles:

Code: Select all

MKCVTBL(TBL_CT, FF_CODE_PAGE) -> TBL_CT ## FF_CODE_PAGE
I am using arm-none-eabi-gcc in gnu99 mode.
Do I need special compiler flags to make this work?
I am using these:

Code: Select all

-Wall -Werror -Wpointer-arith 
-I. -I./mods -I./misc -I./cmsis -I../.. -Ibuild -Ibuild/genhdr -I/mnt/c/ti/TivaWare -I/mnt/c/ti/TivaWare/driverlib -I../../py -I./board -I../../ -Iusbdev/core/inc -Iusbdev/class/inc 
-std=gnu99 -nostdlib -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mabi=aapcs-linux -Og -fshort-enums -fdata-sections -ffunction-sections 
-DPART_TM4C123GH6PM -DTM4C123GH6PM -DARMCM4_FP -DCMSIS_HEADER="ARMCM4_FP.h" -DTARGET_IS_TM4C123_RB1 -DMICROPY_PIN_DEFS_PORT_H="mods/pin_defs_tm4c123.h" -DFFCONF_H="lib/oofatfs/ffconf.h" -DMICROPY_LONGINT_IMPL=MICROPY_LONGINT_IMPL_MPZ -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT 
-fsingle-precision-constant -Wdouble-promotion -ggdb 
-DDEBUG -DPENDSV_DEBUG -DMICROPY_ROM_TEXT_COMPRESSION=1
My project was built on 1.9.4 and I didn't regularly update or anything.
Thanks in advance!

Re: oofatfs problem with macro concat ##

Posted: Fri Jan 15, 2021 4:05 am
by jimmo
What is MICROPY_FATFS_LFN_CODE_PAGE defined as in your mpconfigport.h ?

It probably should be 437, but perhaps it's been changed to (437) ?

Re: oofatfs problem with macro concat ##

Posted: Fri Jan 15, 2021 12:12 pm
by ExXec
It was (437). Changing to 437 fixed it, thanks a lot!