Florian Klaempfl schrieb:

So you want a hybrid pascal/C compiler? Or at which point do you want to
do macro expansion and translation of the resulting C?
All that is done in the compiler front-end, AKA parser.

(preprocessing is never part of the parser, it's a separate compiler
module or part of the, but this doesn't matter)

At least since C98 the preprocessor is part of the parser, due to macro expansion requirements.

Just a simple example:

test.h:

#define POINTER(x) typedef T ## x* x
POINTER(float)

test.pas:

unit test;

interface

  {$I test.h}

A bunch of syntax errors here, because the Pascal preprocessor and parser does not understand C syntax.


  POINTER(longint)

You missed the goal :-(

The C code is translated into separate ppu/o files, which can be added to the Uses clauses. Eventually a library unit or (package?) project can enumerate the types, constants, variables and functions of the C modules, which shall become available in other units. In the case of a library unit this unit can be added to the Uses of other Pascal units.

If you ever had used CBuilder, you would better understand how a compiler can compile modules of various languages, and create object files usable from all languages.

DoDi


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to