3.1.28.2. waf_tools.misc_helpers.to_define
- waf_tools.misc_helpers.to_define(name: str) str
Create a C-style macro name from a provided string.
Every alphanumeric character is upper-cased, every other character is replaced by an underscore. Only ASCII input is supported: non-ASCII characters would either change length when upper-cased (
ß->SS) or produce identifiers that are not portable across compilers, so they are rejected instead of being silently mangled.- Parameters:
name – ASCII string to be converted to a macro.
- Returns:
The macro string, containing only
A-Z,0-9and_.- Raises:
TypeError – If
nameis not astr.ValueError – If
namecontains one or more non-ASCII characters.
Examples
>>> to_define("--ABC_12_xyz") '__ABC_12_XYZ'