I've have experienced a problem when switching workspaces where the PROJECT_NAME variable retains the name of the project from the previous workspace.
Steps to reproduce the problem:
Start Code::Blocks with a blank workspace.
Create a new empty project called A.
In Build Options -> Pre/post build steps add the following:
cmd /C echo $(PROJECT_NAME)
Save the workspace as A.workspace.
Repeat the steps above but name the project B and save the workspace as B.workspace.
Exit Code::Blocks
Start Code::Blocks and open A.workspace.
Build the project. The output will be:
-------------- Build: Debug in A (compiler: GNU GCC Compiler)---------------
Linking stage skipped (build target has no object files to link)
Running target post-build steps
cmd /C echo A
A
Click on File->Recent projects and select B.workspace.
(Don't open via File->Open)
Build the project. The output will be:
-------------- Build: Debug in B (compiler: GNU GCC Compiler)---------------
Linking stage skipped (build target has no object files to link)
Running target post-build steps
cmd /C echo A
A
Note that the command line has incorrectly used A for PROJECT_NAME whereas the Build heading correctly shows B.
Code::Blocks 12.11
WinXP