This is a part of course project in SEU. THIS IS A TOY PROJECT ONLY.
This preprecessor support most of all standard directives and internal macros mentioned in MSDN.
Before all operations, it will perform Line splicing("All lines ending in a backslash (\) immediately followed by a newline character are joined with the next line in the source file, forming logical lines from the physical lines. Unless it's empty, a source file must end in a newline character that's not preceded by a backslash."), and remove all comment without change lineno.
There are equal to #if defined(<MACRO_ID>) and #if !defined(<MACRO_ID>).
- Support calculating most of all interger constants expression in case of
sizeof(size_t) == 8. - Support auto-conversation from
long longtounsigned long long. - Support
defined(<MACRO_ID>)anddefined MACRO_ID. - Support unsigned integer tailing
uorsz(C++23), other tailing letter characters will be ignored(All integer islong longorunsigned long long) and integers representing by a char('[char]') or starting by0x,0bor simple leading zeros will be recognized correctly.
It will raise an error unless is under unsatisified condition directive.
Include one file.
Search path includes specfied by -i parameter and the envirionment variable INCLUDE, which should obey the form in your platform.
Include one file unless it had been included(even by #include).
If this directive is encountered in the same file for the second time, the output of the contents of the current file will be terminated immediately. (It won't check if it is in the head of the whole file).
- Support the detection of the recursion defined.
- Support
__VA_ARGS__. - Support stringizing operator(
#), charizing operator(#@) and token-pasting operator(##).
Clear the defined macro.
__STDC_NO_ATOMICS__always be1.__STDC_NO_COMPLEX__always be1.__STDC_NO_THREADS__always be1.__STDC_NO_VLA__always be1.__STDC_VERSION__always be199901L.__DATE__The date format byMMM dd yyyyinen-USculture.(In .NET; It's equal to the format byMmm dd yyyy),__TIME__The date format byhh:mm:ss.__FILE__the name of current file.(It will covered user-define while switching file.)__LINE__the lineno of current file.
CPreprocessor [options...] [c files...]
Options:
-h | --help | /? show this text
-m | --multi-thread use multi thread to assemble
-s | --show-level define the output show level (verbose|detail|infomation|warning|error|critical)
-f | --overwrite force overwrite file
-o | --output-directoy <directory> output directory
-of | --output-file <filename> output file name
-i | --include-path <directory> add an include path
- String concatenation should be performed after CPreprocessor.(for giving correct lineno to the following parser)
# <lineno> "<filename>"will be added for parser in following step to resolve lineno.- All
#lineand#pragma(without#pragma once) will be pass through. - CPreprocessor won't parse functions, so the predefined identifier(this is not a macro)
__func__won't be replaced by the correct function name.