Tool/software: TI C/C++ Compiler
The following code does not compile with CGT 17.6.0.STS (and probably other versions, I haven't checked).
#define CONCATENATE( a, b ) a ## b
float a = +0x1.c801aap-2;
float b = CONCATENATE( +, 0x1.c801aap-2 );
float c = CONCATENATE( +0x1., c801aap-2 );
float d = CONCATENATE( +0x1.c801aa, p-2 );
CCS output is:
**** Build of configuration Debug for project test_hexfloat_macro ****
"C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
'Building file: ../main.c'
'Invoking: C2000 Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_17.6.0.STS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_17.6.0.STS/include" -g --diag_warning=225 --diag_wrap=off --display_error_number --gen_preprocessor_listing --preproc_with_compile --preproc_dependency="main.d" "../main.c"
>> Compilation failure
subdir_rules.mk:7: recipe for target 'main.obj' failed
"../main.c", line 3: warning #1934-D: concatenation with "0x1.c801aap-2" in macro "CONCATENATE" does not create a valid token
"../main.c", line 4: error #168: invalid floating constant
"../main.c", line 5: error #168: invalid floating constant
2 errors detected in the compilation of "../main.c".
gmake: *** [main.obj] Error 1
gmake: Target 'all' not remade because of errors.
**** Build Finished ****
Yet the preprocessor listing suggests the output of the preprocessor is identical in all instances:
L 1 "../main.c"
N#define CONCATENATE( a, b ) a ## b
Nfloat a = +0x1.c801aap-2;
W "../main.c" 3 11 concatenation with "0x1.c801aap-2" in macro "CONCATENATE" does not create a valid token
Nfloat b = CONCATENATE( +, 0x1.c801aap-2 );
Xfloat b = +0x1.c801aap-2;
E "../main.c" 4 11 invalid floating constant
Nfloat c = CONCATENATE( +0x1., c801aap-2 );
Xfloat c = +0x1.c801aap-2;
E "../main.c" 5 11 invalid floating constant
Nfloat d = CONCATENATE( +0x1.c801aa, p-2 );
Xfloat d = +0x1.c801aap-2;
And the preprocessed source (*.pp file) implies this is also the case:
float a = +0x1.c801aap-2;
float b = +0x1.c801aap-2;
float c = +0x1.c801aap-2;
float d = +0x1.c801aap-2;
What is going on here? Am I violating the C preprocessor standard?