as there is not much of a secret in them, i can put them here. i reduced them to the same file.
this version is used in the CI:
{
"directory": "/home/gitlab-runner/builds/FUEENz7S/0/<redacted>/build_debug/canopen",
"command": "/home/gitlab-runner/ti/compilers/ti-cgt-c2000_6.4.12/bin/cl2000 --compile_only --c_file=/home/gitlab-runner/builds/FUEENz7S/0/<redacted>/ems/canopen/can_sync.c -DAS_1 -DBUILD_WITH_CMAKE -D_DEBUG -D_FLASH --include_path=/home/gitlab-runner/ti/compilers/ti-cgt-c2000_6.4.12/include --include_path=/home/gitlab-runner/builds/FUEENz7S/0/<redacted>/ems/canopen --include_path=<many internal includes> --c99 --relaxed_ansi --silicon_version=28 --large_memory_model --unified_memory --float_support=fpu32 --tmu_support=tmu0 --cla_support=cla1 --opt_level=1 --opt_for_speed=5 --fp_mode=relaxed --advice:performance=all --symdebug:dwarf --diag_wrap=off --diag_warning=225 --display_error_number --preproc_with_compile --emit_warnings_as_errors --output_file=CMakeFiles/canopen.dir/can_sync.c.obj",
"file": "/home/gitlab-runner/builds/FUEENz7S/0/<redacted>/ems/canopen/can_sync.c",
"output": "canopen/CMakeFiles/canopen.dir/can_sync.c.obj"
},
and this version is used locally:
{
"directory": "C:/Users/Malte/GIT/ems/build_debug/canopen",
"command": "C:/ti/kompiler//ti-cgt-c2000_6.4.12/bin/cl2000.exe --compile_only --c_file=C:/Users/Malte/GIT/ems/canopen/can_sync.c -DAS_1 -DBUILD_WITH_CMAKE -D_DEBUG -D_FLASH --include_path=C:/ti/kompiler/ti-cgt-c2000_6.4.12/include --include_path=C:/Users/Malte/GIT/ems/canopen --include_path=<many internal includes> --c99 --relaxed_ansi --silicon_version=28 --large_memory_model --unified_memory --float_support=fpu32 --tmu_support=tmu0 --cla_support=cla1 --opt_level=1 --opt_for_speed=5 --fp_mode=relaxed --advice:performance=all --symdebug:dwarf --diag_wrap=off --diag_warning=225 --display_error_number --preproc_with_compile --emit_warnings_as_errors --output_file=CMakeFiles/canopen.dir/can_sync.c.obj",
"file": "C:/Users/Malte/GIT/ems/canopen/can_sync.c",
"output": "canopen/CMakeFiles/canopen.dir/can_sync.c.obj"
},
as you can see, they are identical (ignoring folder names, and ignoring the .exe on windows). there is an important difference though: sonarlint in vscode refuses to work without seeing this file, while sonarscanner in the CI has absolutely no problem without having a compile database. in fact, in our CI, sonarscanner would not be able to access this file at all, but still managed to analyze the source and find issues, though none of them related to the missing defines.
we then added the option -Dsonar.cfamily.compile-commands to the sonarscanner command line, and sure enough it does now fail with the same defines missing. so now, both sonarscanner AND sonarlint don’t work, sonarscanner giving out the error that the defines are not found, and sonarlint silently failing. this is an improvement as we can now go about adding those defines in to make both of them happy at once, I hope. The problem is now narrowed down to the compiler using intrinsic defines which it will not list when probed.
still this raises the question: if sonar.cfamily.compile-commands is not used and sonarscanner does not get a compilation database - what does it compile with? does it compile at all?
also, if someone else finds this thread in the future: newer versions of the c2000 compiler do actually report the correct defines when probed, this error will happen with older versions of the c2000 compiler which do use the defines internally, but dont report them when probed.