Enabling FPC_HAS_FEATURE_CONSOLEIO

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Enabling FPC_HAS_FEATURE_CONSOLEIO

leledumbo
Administrator
I need FPC (or better, Pascal) console IO feature for my OS. That is, Write(Ln) (and possibly Read(Ln)) with variable number and type of arguments. I already have my own, but each can only take one argument. So, a statement like:

WriteLn('Hello, I am ',20,' years old');

must be splitted into:

WriteString('Hello, I am ');
WriteLong(20);
WriteStrLn(' years old');

This is very inconvenient. Moreover, assertions needs it. My first attempt, is to comment out {$undef FPC_HAS_FEATURE_CONSOLEIO} in my system.pas. But then, FPC argues about Unknown compilerproc "fpc_write_text_shortstr". I found it in text.inc, but it's only included if FPC_HAS_FEATURE_TEXTIO is defined. Knowing that I don't yet have any file system driver, I guess it's impossible to reach my goal by defining it.
What's the correct way?
Reply | Threaded
Open this post in threaded view
|

Re: Enabling FPC_HAS_FEATURE_CONSOLEIO

Mattias Gaertner
On Mon, 28 Jul 2008 02:12:35 -0700 (PDT)
leledumbo <[hidden email]> wrote:

>
> I need FPC (or better, Pascal) console IO feature for my OS. That is,
> Write(Ln) (and possibly Read(Ln)) with variable number and type of
> arguments. I already have my own, but each can only take one
> argument. So, a statement like:
>
> WriteLn('Hello, I am ',20,' years old');
>
> must be splitted into:
>
> WriteString('Hello, I am ');
> WriteLong(20);
> WriteStrLn(' years old');

Can you use variants?

procedure DebugLn(Args: array of const);
var
  i: Integer;
begin
  for i:=Low(Args) to High(Args) do begin
    case Args[i].VType of
    vtInteger: writeln(IntToStr(Args[i].vinteger));
    vtInt64: writeln(IntToStr(Args[i].VInt64^));
    ...
  end;
end;

See lazarus lclproc.pas for a complete example.

 
> This is very inconvenient. Moreover, assertions needs it. My first
> attempt, is to comment out {$undef FPC_HAS_FEATURE_CONSOLEIO} in my
> system.pas. But then, FPC argues about Unknown compilerproc
> "fpc_write_text_shortstr". I found it in text.inc, but it's only
> included if FPC_HAS_FEATURE_TEXTIO is defined. Knowing that I don't
> yet have any file system driver, I guess it's impossible to reach my
> goal by defining it. What's the correct way?

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Enabling FPC_HAS_FEATURE_CONSOLEIO

leledumbo
Administrator

Mattias Gaertner wrote
Can you use variants?
No, it requires objfpc support which I don't have yet (see my other post about  FPC_HAS_FEATURE_HEAP). What if I declare fpc_write_text_shortstr with the same signature as the one in text.inc?
Reply | Threaded
Open this post in threaded view
|

Re: Enabling FPC_HAS_FEATURE_CONSOLEIO

Micha Nelissen
In reply to this post by leledumbo
leledumbo wrote:
> This is very inconvenient. Moreover, assertions needs it. My first attempt,
> is to comment out {$undef FPC_HAS_FEATURE_CONSOLEIO} in my system.pas. But
> then, FPC argues about Unknown compilerproc "fpc_write_text_shortstr". I
> found it in text.inc, but it's only included if FPC_HAS_FEATURE_TEXTIO is
> defined. Knowing that I don't yet have any file system driver, I guess it's
> impossible to reach my goal by defining it.
> What's the correct way?

Can you undefine FPC_HAS_FEATURE_TEXTIO as well?

In the end, you have nothing left :-). Or is this the point?

What's the goal?

Micha
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Enabling FPC_HAS_FEATURE_CONSOLEIO

leledumbo
Administrator
Micha Nelissen wrote
Can you undefine FPC_HAS_FEATURE_TEXTIO as well?

In the end, you have nothing left :-). Or is this the point?
It's already undefined. Yes, I have nothing for now. In systemh.inc, you may find:

{$ifndef FPC_HAS_FEATURE_SUPPORT}
{$define FPC_HAS_FEATURE_HEAP}
{$define FPC_HAS_FEATURE_INITFINAL}
{$define FPC_HAS_FEATURE_RTTI}
{$define FPC_HAS_FEATURE_CLASSES}
{$define FPC_HAS_FEATURE_EXCEPTIONS}
{$define FPC_HAS_FEATURE_EXITCODE}
{$define FPC_HAS_FEATURE_ANSISTRINGS}
{$define FPC_HAS_FEATURE_WIDESTRINGS}
{$define FPC_HAS_FEATURE_TEXTIO}
{$define FPC_HAS_FEATURE_CONSOLEIO}
{$define FPC_HAS_FEATURE_FILEIO}
{$define FPC_HAS_FEATURE_RANDOM}
{$define FPC_HAS_FEATURE_VARIANTS}
{$define FPC_HAS_FEATURE_OBJECTS}
{$define FPC_HAS_FEATURE_DYNARRAYS}
{$define FPC_HAS_FEATURE_THREADING}
{$define FPC_HAS_FEATURE_COMMANDARGS}
{$define FPC_HAS_FEATURE_PROCESSES}
{$define FPC_HAS_FEATURE_STACKCHECK}
{$define FPC_HAS_FEATURE_DYNLIBS}
{$endif FPC_HAS_FEATURE_SUPPORT}

and my quick way to get rid of errors is to declare:

{$define FPC_HAS_FEATURE_SUPPORT}
{$undef FPC_HAS_FEATURE_HEAP}
{$undef FPC_HAS_FEATURE_INITFINAL}
{$undef FPC_HAS_FEATURE_RTTI}
{$undef FPC_HAS_FEATURE_CLASSES}
{$undef FPC_HAS_FEATURE_EXCEPTIONS}
{$undef FPC_HAS_FEATURE_EXITCODE}
{$undef FPC_HAS_FEATURE_ANSISTRINGS}
{$undef FPC_HAS_FEATURE_WIDESTRINGS}
{$undef FPC_HAS_FEATURE_TEXTIO}
{$undef FPC_HAS_FEATURE_CONSOLEIO}
{$undef FPC_HAS_FEATURE_FILEIO}
{$undef FPC_HAS_FEATURE_RANDOM}
{$undef FPC_HAS_FEATURE_VARIANTS}
{$undef FPC_HAS_FEATURE_OBJECTS}
{$undef FPC_HAS_FEATURE_DYNARRAYS}
{$undef FPC_HAS_FEATURE_THREADING}
{$undef FPC_HAS_FEATURE_COMMANDARGS}
{$undef FPC_HAS_FEATURE_PROCESSES}
{$undef FPC_HAS_FEATURE_STACKCHECK}
{$undef FPC_HAS_FEATURE_DYNLIBS}

in my system.pas. That way, I got my minimal working rtl (includes support for ShortStrings, Sets, etc. so it's not totally *nothing*).
Micha Nelissen wrote
What's the goal?
I want to enable them one by one until all those defines are gone, so I have a full FPC support in my OS. And one of the first two (the other is HEAP) I can think of is the CONSOLEIO since I already have console printing ability.
Perhaps someone have a dependency graph for all of these features?
Reply | Threaded
Open this post in threaded view
|

Re: Enabling FPC_HAS_FEATURE_CONSOLEIO

Florian Klämpfl
leledumbo schrieb:
> Perhaps someone have a dependency graph for all of these features?

This is probably too hard to do. The goal of the feature approach is
designed more towards the possibility to create a stripped rtl for
existing targets. If you want only consoleio without file system support
I fear you need to take your own approach
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Enabling FPC_HAS_FEATURE_CONSOLEIO

leledumbo
Administrator
Florian Klaempfl wrote
If you want only consoleio without file system support
I fear you need to take your own approach
No workaround?

I'll implement a file system soon, so I guess I'll be fine. Except there's another feature dependency for CONSOLEIO besides TEXTIO.

PS: FILEIO looks ... suspicious (i.e. not much different from TEXTIO).