Table of contents.
Characters and Strings.
Single characters and string literals in StrictAL almost the same
as in ANSI C with few minor differences. They can be defined only as
char
type. There is no wchar_t
data
type and no need to specify L
prefix before quotes. The
compiler makes a choice between single-byte characters and wide
characters depending on compilation flags.
Characters are enclosed in single quotes.
Strings are enclosed in double quotes and follows the rules:
- It can be splitted into parts and occupy several lines.
- It can contain only
'\n'
,'\t'
and'\"'
escape sequences. - It can not be empty (
""
).
char *text = "Even the smallest person can "
"change the course of the future.";
char *text = "May it be a light to you in dark
places, when all other lights go out.";
SALCONV
wraps all constant strings with
_T()
macro:
// After conversion:
char someText[] = _T("Hello, World!");
Comments.
StrictAL supports the same types of comments as C99 (single-line and multi-line). Single-line comment starts with two forward slashes (//) and ends in the end of the line. Multi-line comment is contained in block opened by forward slash with asterisk (/*) and closed by asterisk with forward slash (*/). Multi-line comments cannot be nested.
/* And I'am a multi-line comment
with a lot of useful information. */
SALCONV
changes all single-line comments to multi-line
type:
After conversion:
/* Some ordinary comment. */
Escaped characters.
To escape a character backslash (\) is used. Escaped characters are allowed only in single-quoted and double-quoted strings with some restrictions, usage of backslashes outside of comments and strings will rise a compilation error. Escaping of line ending is prohibited in any cases.
char *text = "It's called \"An Unexpected Party\".";
// Invalid code:
char *text = "First part of the text \
Second part of the text";
Source files.
Files with source code have ".sals" file extension and must contain only spaces, horizontal tabulations, newlines and visible printable ASCII characters.