Re: [fpc-devel] Declare variables inside the code

2011-05-12 Thread Michael Schnell

On 05/11/2011 06:48 PM, Joerg Schuelke wrote:


I would introduce a macro expansion trough a compiler directive.
What a bout a compiler directive to optionally call the gnu C 
preprocessor ? I would have wanted used this some time ago for a very 
special project.


-Michael
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Declare variables inside the code

2011-05-12 Thread Jonas Maebe

On 12 May 2011, at 04:11, kingbiz...@gmail.com wrote:

 But something that has been pointed (by Joerg I belive) is the initialization 
 of variables, what about it? This would be a nice thing and I don't see why 
 not. I prefer to see:
 
 *var
   X: Integer = 0;
   Y: Integer = 100;*

This is already supported (and least in Delphi and ObjFPC modes, I'm not sure 
about the other ones).


Jonas___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Declare variables inside the code

2011-05-12 Thread Jonas Maebe


On 12 May 2011, at 09:32, Michael Schnell wrote:


On 05/11/2011 06:48 PM, Joerg Schuelke wrote:


I would introduce a macro expansion trough a compiler directive.
What a bout a compiler directive to optionally call the gnu C  
preprocessor ? I would have wanted used this some time ago for a  
very special project.


You cannot use cpp, because it cannot deal with Pascal comments (as a  
result it sometimes interprets text inside Pascal comments as the  
start of a C-style comment, and removes all of the source code coming  
after it).


gpc -E works better, but
a) it adds # 1 file.xxx pseudo-statements that indicate which source  
file starts at that point (cpp inserts the same ones, so using that  
one instead would not help)
b) it inlines the constents of {$include xxx} statements (so the  
compiler-inserted debug information would no longer be correct, unless  
you teach it to parse those # 1 file.xxx statements), and  
furthermore also leaves the original {$include xxx} statement in the  
source (so the compiler would process it twice)


I don't think it would be a problem to add support for calling an  
external preprocessor if someone would write one though.



Jonas

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Declare variables inside the code

2011-05-12 Thread Joerg Schuelke
Am Thu, 12 May 2011 09:32:28 +0200
schrieb Michael Schnell mschn...@lumino.de:

 What a bout a compiler directive to optionally call the gnu C 
 preprocessor ? I would have wanted used this some time ago for a very 
 special project.

Thats a merrily idea: This would mean writing macro definitions to a
temporary file and then calling the C preprocessor to process them and
then including the result.

As a joy, OK, sounds good.

Jörg
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Declare variables inside the code

2011-05-12 Thread Jonas Maebe


On 12 May 2011, at 10:21, Jonas Maebe wrote:

b) it inlines the constents of {$include xxx} statements (so the  
compiler-inserted debug information would no longer be correct


This is actually a general problem with preprocessed source files: the  
line information inserted by the compiler will almost certainly no  
longer correspond to the original source, but to the preprocessed  
source instead (unless support is added for some kind of line  
directives, but that's a whole other thing that just supporting  
calling an external program to preprocess sources).



Jonas

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Declare variables inside the code

2011-05-12 Thread michael . vancanneyt



On Thu, 12 May 2011, Jonas Maebe wrote:



On 12 May 2011, at 10:21, Jonas Maebe wrote:

b) it inlines the constents of {$include xxx} statements (so the 
compiler-inserted debug information would no longer be correct


This is actually a general problem with preprocessed source files: the line 
information inserted by the compiler will almost certainly no longer 
correspond to the original source, but to the preprocessed source instead 
(unless support is added for some kind of line directives, but that's a whole 
other thing that just supporting calling an external program to preprocess 
sources).


Good reasons to avoid preprocessor support in the compiler. Anyone needing it 
can perfectly do this manually with makefiles and e.g. m4. Lazarus has support 
for it as well, so this should not stop anyone.


I prefer a smaller mean and lean compiler to a bloatware and slow compiler.

One day, we'll end up adding email support to the compiler.

Michael.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Declare variables inside the code

2011-05-12 Thread Hans-Peter Diettrich

Michael Schnell schrieb:

What a bout a compiler directive to optionally call the gnu C 
preprocessor ? I would have wanted used this some time ago for a very 
special project.


IMO you can do that with build macros. But note that you'll have to use 
the C macro syntax (#define...), for such stuff.


You also can use the preprocessor of ToPas, to preprocess source files, 
optionally with your own macro syntax - if you implement it.


DoDi

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel