Difference between revisions of "Per-project variables"

From Code::Blocks
(Created page with "Category:User Documentation In addition to global variables, Code::Blocks supports usage of variables whose definition is stored within a projec...")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
In addition to [[Global compiler variables|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.
 
In addition to [[Global compiler variables|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 <tt>$(variable)</tt>. It is often useful to use project variables to manage filename pre/post-fixes, as it enables all occurrences to be changed simultaneously.
+
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:
  
''Note: all [[Global compiler variables#Constraints|global variable constraints]] apply to per-project variables as well.''
+
* <code>$VARIABLE</code>
 +
* <code>$(VARIABLE)</code>
 +
* <code>${VARIABLE}</code>
 +
* <code>%VARIABLE%</code>
 +
 
 +
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 compiler variables#Constraints|global variable naming constraints]] apply to per-project variables.''
 +
 
 +
== See also ==
 +
* [[Variable expansion#List of available builtins|List of predefined variables]]
 +
* [[Code::Blocks variable types synthesis]]

Latest revision as of 15:09, 8 October 2011

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