I'm not sure I understand what is expected to happen and what happens in your environment.
Can you explain? Provide a log?
Sure - here is my commented log
-------------- Clean: Debug in VariableExpansion (compiler: GNU GCC Compiler)---------------
Cleaned "VariableExpansion - Debug"
[ 25.0%] Running target pre-build steps
An entered slash (original version of PATH_SLASH was './main.c') saved as backslash in .cpb as shipped in my tiny example ... This is the crux of the whole thing here I believe.
[ 50.0%] echo PATH_SLASH: .\main.c
PATH_SLASH: .\main.c
Effectively the same since PATH_SLASH and PATH_BACKSLASH have same values unfortunately:
[ 75.0%] echo PATH_BACKSLSASH: .\main.c
PATH_BACKSLSASH: .\main.c
TO_UNIX_PATH properly converts a backslash to a slash when given as pre-build command
[100.0%] echo TO_UNIX_PATH{(PATH_SLASH)}: ./main.c
TO_UNIX_PATH(PATH_SLASH): ./main.c
echo TO_UNIX_PATH{(PATH_BACKSLASH)}: ./main.c
linux dislikes the next line apparently ... no idea why:
TO_UNIX_PATH(PATH_BACKSLASH): ./main.c
The next section runs the compiler directive to compile 'main.x' with target 'main.xx' - like %.xx: %.x in make syntax - with the following compiler commands (from 'compiler_config.txt' in my .7z docarated with some comments):
NB: Typo in the definition of $PATH_BACKSLASH_MACRO: Should be '$TO_UNIX_PATH' (instead of 'PATH_TO_UNIX'). Please amend in the .cbp.echo 1 - PATH_BACKSLASH: $(PATH_BACKSLASH) // works - expand project variable
echo 2 - TO_UNIX_PATH(PATH_BACKSLASH): $TO_UNIX_PATH{$(PATH_BACKSLASH)} // works - expand function (in compiler command (!)) applied to project variable
echo 3 - $PATH_BACKSLASH_MACRO // fails - expand defined as project variable defined '$TO_UNIX_PATH{$PATH_BACKSLASH}' to see when functions are parsed and expanded
echo 4 - $$(PATH_BACKSLASH_MACRO) // fails - just tried because of the documentation given in the project variable definition window which appears to be confusing in the light of the result of the forth command
... back to my log again:
-------------- Build: Debug in VariableExpansion (compiler: GNU GCC Compiler)---------------
[ 16.7%] mingw32-gcc.exe -Wall -g -c C:\myDevel\myprogs\CodeBlocks\VariableExpansion\main.c -o obj\Debug\main.o
here the user-defined compiler step:
[ 33.3%] echo 1 - PATH_BACKSLASH: .\main.c
echo 2 - TO_UNIX_PATH(PATH_BACKSLASH): ./main.c
echo 3 - {.\main.c
echo 4 - $(PATH_BACKSLASH_MACRO)
1 - PATH_BACKSLASH: .\main.c
2 - TO_UNIX_PATH(PATH_BACKSLASH): ./main.c
3 -
4 - $(PATH_BACKSLASH_MACRO)
[ 50.0%] mingw32-g++.exe -o bin\Debug\VariableExpansion.exe obj\Debug\main.o -static-libgcc -static-libstdc++
Output file is bin\Debug\VariableExpansion.exe with size 31.97 KB
The test above check how/when built-in functions are expanded. However my basic question I was starting off with was is why a slash the user edits in some config interfact is saved as backslash in the .cbp xml structure? Is there any need for that? As a not so nice workaround I solved the issue by explicitly using a conversion function in a compiler directive.
NB: It appears that the functions like 'TO_UNIX_PATH' convert every slash or backslash appropriately, regardless if the argument is a proper path or not.
Sorry again for that lengthy thing here, but you asked for that.