Overview of how to use the VEX language compiler vcc and its pre-processor and pragma statements.
The vcc compiler compiles VEX source code into a form executable by
Houdini. The VEX compiler (vcc) is capable of compiling VEX code,
generating dialog scripts for VEX functions, and also giving quick help
by listing the global variables and functions available in any given context.
Command-line options
-?, -H, -h
| Show help message for the compiler. |
-X context_name
| Display a list of a global variables, statements, and functions
which are valid in the given context. The available contexts are
listed in the help message ( |
-D name=def, -D name
| Define a macro for the pre-processor. If no value is given with the name, the name is defined as 1. |
-I path
| Add the path specified to the include path (the list of directories
search for files referenced by the |
-o file
| Output to |
-c
| Generate a binary/encrypted version of the
file . The generated |
-e file
| Redirect errors from STDERR to file. |
-w wlist
| Suppress printing of certain warnings. wlist is a comma-separated list of warning numbers to suppress. |
-q, -Q
| Quiet. Lower-case q suppresses normal messages. Upper-case Q suppresses messages and warnings. Both options still print errors. |
-i
| Make the generated |
-u, -U
| Generate a corresponding dialog script for the VEX function. Houdini
can use the script to create a window to let the user modify
parameters interactively (rather than editing a string). If you use
|
-g n
| When generating dialog scripts with the |
-v
| Extract parameter information and build a dialog script from
compiled |
Preprocessor
The compiler has a pre-processor which strips comments, expands macros, and optionally encrypts the output.
The pre-processor supports many of the usual C Pre-Processor directives:
#define name token-string
| Replace subsequent uses of name with token-string. | ||||||||
#define name(arg,...,arg) token-string
| Replace subsequent instances of name with token-string. Each argument to name is replaced in token-string during expansion. | ||||||||
#undef name
| “Undefine” the macro so subsequent uses of name are not expanded. | ||||||||
#include "filename"
| Inserts the contents of the file at this point in the source code. When you use quotes, the directory containing the current file is searched for filename before the standard locations (including the path). | ||||||||
#ifdef name
| The following lines until the next | ||||||||
#ifndef name
| The lines following will be compiled if and only if name is not a defined macro. | ||||||||
#if constant-expr
| The following lines until the next The expression can use the following operators:
The expression can also use the following functions:
Expressions are evaluated from left to right (unlike the ANSI C standard of right to left). As with the ANSI pre-procssor, all numbers must be integers. | ||||||||
#else
| The following lines until the next | ||||||||
#endif
| Marks the end of a section of conditional code. Every test directive
must have a matching | ||||||||
#pragma ...
| Specifies extended language features. See the list of pragmas. |
Predefined macros
The following macros are pre-defined:
__vex
| This symbol is always defined. You can use this in an |
__vex_major
| The major version number of the compiler. |
__vex_minor
| The minor version number of the compiler. |
__LINE__
| The current line number of the source file. |
__FILE__
| The file being compiled. |
__DATE__
| The current date (as a quoted string). Example: |
__TIME__
| The current time (as a quoted string). Example: |
printf("Starting shader %s at %s", __FILE__, __DATE__);
Code encryption
In some cases you may want to produce compiled code that is not human-readable. For example, your code may contain proprietary algorithms you don’t want to become public knowledge.
You can encrypt an entire file with the -c compiler flag, or mark a
block of code to be encrypted with the #pragma crypt and #pragma
endcrypt pre-processor directives:
float wavenoise(float height, float distance) { #pragma crypt return sin(distance)*height; #pragma endcrypt }When this code is compiled it is encrypted to be reasonable secure.
You may sometimes need to encrypt the proprietary information in the
source code (especially since vcc doesn’t support linking in library
code). You can use the vcrypt utility to encrypt the parts of the
source code designated by #pragma crypt. The compiler will be able to
read and compile the encrypted source code.
If the compiler detects encrypted source in its input stream, the final output will be encrypted. This means it’s not possible to reverse engineer an encrypted function by compiling it and decoding the assembler output.