This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
C PreProcessor GCC-specific features ideas.
- From: Solal <solal dot rastier at me dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 22 Apr 2014 18:38:35 +0200
- Subject: C PreProcessor GCC-specific features ideas.
- Authentication-results: sourceware.org; auth=none
I've got ideas for improve the preprocessor with specific features.
The basic idea is to make the preprocessing language a complete
programming language.
That can be useful for includes things like Autotools and advanced
Makefiles directly in the source code, and have just a tiny Makefile for
compile.
0. Multiple defines on one variable.
The "constants" will be transformed in "variables".
1. Assertions
#assert <CONDITION> <COMMAND-TO-EXECUTE-CONDITION-IS-FALSE>
will be transformed in :
#if !<CONDITION>
#<CMD>
#endif
(And will be of course re-preprocessed.)
2. Calculating
#calculate <VAR> <CALCUL>
will be transformed in :
#define <VAR> <RESULT>
(And will be of course re-preprocessed.)
Example :
#calculate N 1+1
will be transformed in :
#define N 2
(That can works with any type : bools, etc.)
3. Executing shell commands
#exec-sh <VAR> <SHELL-COMMAND>
The shell command <SHELL-COMMAND> while be executed and the result
(stdout) of the shell command will be putted in <VAR>
4. Read and write files
#read-file <VAR> <FILENAME>
will put the content of the file <FILENAME> in <VAR>, and if <VAR> is
modified, <FILENAME> is modified too.