Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-07

Enabling FPC_HAS_FEATURE_CONSOLEIO

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

leledumbo

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?

View this message in context: http://www.nabble.com/Enabling-FPC_HAS_FEATURE_CONSOLEIO-tp18686657p18686657.html Sent from the Free Pascal - General mailing list .
Mattias Gaertner
to leledumbo
Show quoted text 13 lines
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.

Show quoted text 7 lines
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

Micha Nelissen
to leledumbo: I need FPC (or better, Pascal) console IO feature for my OS. That is, Write(Ln) (and…
leledumbo wrote 7 lines
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

leledumbo
to Micha Nelissen
Micha Nelissen wrote 9 lines
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

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, Set, etc. so it's not totally *nothing*). 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?

View this message in context: http://www.nabble.com/Enabling-FPC_HAS_FEATURE_CONSOLEIO-tp18686657p18770484.html Sent from the Free Pascal - General mailing list .
Florian Klaempfl
to leledumbo
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

leledumbo
to Florian Klaempfl
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).

View this message in context: http://www.nabble.com/Enabling-FPC_HAS_FEATURE_CONSOLEIO-tp18686657p18771747.html Sent from the Free Pascal - General mailing list .