Recent

Author Topic: How to DIY a filerec record in system.pas by DIY in Bare Metal?  (Read 927 times)

TYDQ

  • Full Member
  • ***
  • Posts: 129
These days I have met an problem like this:
If I complie my bare metal using -g parameter,I will get an error like this:
system.pas(324,10) Fatal: Cannot find system type "FILEREC". Check if you use the correct run time library.
Fatal: Compilation aborted
So,How to write my own filerec record for my program?

TRon

  • Hero Member
  • *****
  • Posts: 4353
Re: How to DIY a filerec record in system.pas by DIY in Bare Metal?
« Reply #1 on: April 19, 2025, 10:08:46 am »
You write that you are using a custom rtl (bare metal). Then you write to encounter an error about a certain missing type which means that you have not integrated that into your custom rtl.

Have do you propose we handle such question(s) without having any access to or knowledge about your custom rtl or where that rtl is running?

On a general note, the compiler uses a define "FPC_HAS_FEATURE_FILEIO" which compiles in the required pieces. If your hosting environment does not offer support for any of the required/depending functionality then you would have to implement a custom solution.
Today is tomorrow's yesterday.

Thaddy

  • Hero Member
  • *****
  • Posts: 16937
  • Ceterum censeo Trump esse delendam
Re: How to DIY a filerec record in system.pas by DIY in Bare Metal?
« Reply #2 on: April 19, 2025, 11:18:33 am »
I would simply lift it from the compiler sources.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

TYDQ

  • Full Member
  • ***
  • Posts: 129
Re: How to DIY a filerec record in system.pas by DIY in Bare Metal?
« Reply #3 on: April 20, 2025, 03:31:53 am »
I would simply lift it from the compiler sources.
Emm.....What is the name of FILEREC in compiler sources(Maybe sys_filerec?),I was directly using grep -r FILEREC in the root path of the fpc source code and gain no related records of FILEREC just FILEREC String and its location.

TYDQ

  • Full Member
  • ***
  • Posts: 129
Re: How to DIY a filerec record in system.pas by DIY in Bare Metal?
« Reply #4 on: April 20, 2025, 03:35:47 am »
You write that you are using a custom rtl (bare metal). Then you write to encounter an error about a certain missing type which means that you have not integrated that into your custom rtl.

Have do you propose we handle such question(s) without having any access to or knowledge about your custom rtl or where that rtl is running?

On a general note, the compiler uses a define "FPC_HAS_FEATURE_FILEIO" which compiles in the required pieces. If your hosting environment does not offer support for any of the required/depending functionality then you would have to implement a custom solution.
Yes,does the filerec is OS-specific or having same definition in every architecture that fpc supports?

TRon

  • Hero Member
  • *****
  • Posts: 4353
Re: How to DIY a filerec record in system.pas by DIY in Bare Metal?
« Reply #5 on: April 20, 2025, 03:59:17 am »
Yes,does the filerec is OS-specific or having same definition in every architecture that fpc supports?
The answer might surprise you: it is both. The structure is static but contains private data that might be (ab)used on a per OS base.

Why not have a look at it yourself ? It is defined in the RTL file filerec.inc. No idea why that not showed up for you in your grep.
Today is tomorrow's yesterday.

TYDQ

  • Full Member
  • ***
  • Posts: 129
Re: How to DIY a filerec record in system.pas by DIY in Bare Metal?
« Reply #6 on: April 20, 2025, 05:59:45 am »
Yes,does the filerec is OS-specific or having same definition in every architecture that fpc supports?
The answer might surprise you: it is both. The structure is static but contains private data that might be (ab)used on a per OS base.

Why not have a look at it yourself ? It is defined in the RTL file filerec.inc. No idea why that not showed up for you in your grep.
Thank you.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12189
  • FPC developer.
Re: How to DIY a filerec record in system.pas by DIY in Bare Metal?
« Reply #7 on: April 20, 2025, 02:45:50 pm »
I would simply lift it from the compiler sources.
Emm.....What is the name of FILEREC in compiler sources(Maybe sys_filerec?),I was directly using grep -r FILEREC in the root path of the fpc source code and gain no related records of FILEREC just FILEREC String and its location.

Try harder, it is in fpc/rtl/inc/filerec.inc

The file has even got the same name.

TYDQ

  • Full Member
  • ***
  • Posts: 129
Re: How to DIY a filerec record in system.pas by DIY in Bare Metal?
« Reply #8 on: April 21, 2025, 10:58:11 am »
I would simply lift it from the compiler sources.
Emm.....What is the name of FILEREC in compiler sources(Maybe sys_filerec?),I was directly using grep -r FILEREC in the root path of the fpc source code and gain no related records of FILEREC just FILEREC String and its location.

Try harder, it is in fpc/rtl/inc/filerec.inc
Thank you,I have alternative way to debug and avoid using filerec record in my program.

The file has even got the same name.

 

TinyPortal © 2005-2018