Per-project variables

From Code::Blocks
Revision as of 14:55, 8 October 2011 by Alpha (talk | contribs)

In addition to global variables, Code::Blocks supports usage of variables whose definition is stored within a project. To create a project variable, open Project->Build options...->Custom variables (tab). From the tree selection on the left-hand side, Code::Blocks offers the option of having the variable defined for the entire project, or per build target.

The center box contains a list of all currently defined project variables (this is often empty). Any variable defined here is accessible through the following styles:

  • $VARIABLE
  • $(VARIABLE)
  • ${VARIABLE}
  • %VARIABLE%

It is often useful to use project variables to manage filename pre/post-fixes, as it enables all occurrences to be changed simultaneously.

Note: although variable definitions allow for the inclusion of other variables within them, care must be taken to insure an infinite loop is not created; Code::Blocks will detect and report many (but not all) erroneous definitions. Also, all global variable naming constraints apply to per-project variables.

See also