Sign in Join

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

Mailing lists / fpc-devel / 2005-12

functions within record declarations

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Christopher Cureau

Hi there!

I've been trying to compile some code that used to work in version 1.0.10 of the compiler, but now seems to give errors. In each of the errors below, it looks like a function is being put into a record, and the compiler doesn't like it. I have pasted the relevant lines from fs.inc below along with the errors that the compiler throws.

Can anyone shed some light onto what has changed between compiler versions?

Thanks,
Chris Cureau

code: (line number prefixes...)

103:   file_system_type = record
104:     name       : string[20];
105:      fs_flag    : dword;
106:      read_super : function (sb : P_super_block_t) : P_super_block_t;
107:      next       : ^file_system_type;
108:   end;

error:

Compiling kernel/main.pp
Free Pascal Compiler version 2.0.0 [2005/09/09] for i386 Copyright (c) 1993-2005 by Florian Klaempfl
Target OS: Linux for i386
Compiling ./src/kernel/main.pp
fs.inc(107,37) Error: Type "file_system_type" is not completely defined mm.inc(31,34) Error: Type "T_page_desc" is not completely defined mm.inc(58,25) Error: Type "mmap_req" is not completely defined mm.inc(59,25) Error: Type "mmap_req" is not completely defined process.inc(109,35) Error: Type "pid_table_struct" is not completely defined
main.pp(130,22) Error: Incompatible types: got "SmallInt" expected "Pointer"
main.pp(131,22) Error: Incompatible types: got "LongWord" expected "Pointer"
main.pp(207) Fatal: There were 7 errors compiling module, stopping main.pp(207) Error: Compilation aborted

Reply by email

Tomas Hajny

Christopher Cureau wrote:

Hi,

Show quoted text 20 lines
I've been trying to compile some code that used to work in version 1.0.10 of the compiler, but now seems to give errors. In each of the errors below, it looks like a function is being put into a record, and the compiler doesn't like it. I have pasted the relevant lines from fs.inc below along with the errors that the compiler throws. Can anyone shed some light onto what has changed between compiler versions? Thanks, Chris Cureau code: (line number prefixes...) 103: file_system_type = record 104: name : string[20]; 105: fs_flag : dword; 106: read_super : function (sb : P_super_block_t) : P_super_block_t; 107: next : ^file_system_type; 108: end;

First, it's easier if you provide a directly compilable example. Second, changing your type declaration as shown below should make it to compile.

type
  P_Super_block_t = pointer;
  Pfile_system_type = ^file_system_type
  file_system_type = record
    name       : string[20];
    fs_flag    : dword;
    read_super : function (sb : P_super_block_t) : P_super_block_t;
    next       : Pfile_system_type;
  end;
begin
end.

Tomas

Reply by email

Daniël Mantione
to Christopher Cureau: Hi there! I've been trying to compile some code that used to work in version 1.0.10 of…

Op Mon, 5 Dec 2005, schreef Christopher Cureau:

Show quoted text 8 lines
code: (line number prefixes...) 103: file_system_type = record 104: name : string[20]; 105: fs_flag : dword; 106: read_super : function (sb : P_super_block_t) : P_super_block_t; 107: next : ^file_system_type; 108: end;

Line 107 is invalid Pascal. 1.0.10 must have accepted it while it should not. Define a separate pointer type, and it'll work better.

Daniel

Reply by email