Recent

Author Topic: type's already defined in system.pas  (Read 3010 times)

paule32

  • Full Member
  • ***
  • Posts: 233
type's already defined in system.pas
« on: February 20, 2024, 07:30:23 pm »
Hello, I have this Snippet of my custom system.pas ...
why is BYTE, WORD, and QWORD already defined, but not DWORD ?

Code: Pascal  [Select][+][-]
  1. {$mode delphi}
  2. unit system;
  3.  
  4. interface
  5. type Short_BYTE  =                 -128..127;
  6. type Short_WORD  =               -32768..32767;
  7. type Short_DWORD =          -2147483648..2147483647;
  8. type Short_QWORD = -9223372036854775808..9223372036854775807;
  9.  
  10. type BYTE     =  0..255;  // error
  11. type WORD     =  0..65535;  // error
  12. type DWORD    =  0..4294967295;
  13. type QWORD    =  0..18446744073709551615;  // error

xixixi

  • New Member
  • *
  • Posts: 25
Re: type's already defined in system.pas
« Reply #1 on: February 20, 2024, 07:47:09 pm »
Because it's called "LongWord", as a counterpart of LongInt.

A synonym is "Cardinal".

Thaddy

  • Hero Member
  • *****
  • Posts: 14614
  • Sensorship about opinions does not belong here.
Re: type's already defined in system.pas
« Reply #2 on: February 20, 2024, 07:50:21 pm »
dword is aliased from cardinal, which is a pascal native type.
Do you really compile your system.pas with the proper compiler option? -Us
« Last Edit: February 20, 2024, 07:55:54 pm by Thaddy »
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

paule32

  • Full Member
  • ***
  • Posts: 233
Re: type's already defined in system.pas
« Reply #3 on: February 20, 2024, 08:08:09 pm »
@Thaddy:

yes, I use -Us - like the Documentation describe, when I would compile a system.pas unit.

DWORD brings me no Error...

But, how are BYTE, and WORD declared - it bring me Error ?

BYTE can be from 0..255  (not signed)
BYTE can be from -128..127  (signed )

WORD can be from 0..65535 (not signed)
WORD can be from -32768..32767 (signed)

and so far, and so forth...

So, I have no Change, to set the Types for custom Size ?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5519
  • Compiler Developer
Re: type's already defined in system.pas
« Reply #4 on: February 20, 2024, 09:02:50 pm »
But, how are BYTE, and WORD declared - it bring me Error ?

They are builtin types provided by the compiler you can not redeclare them inside the System unit, because the compiler automatically injects them there.

BYTE can be from 0..255  (not signed)
BYTE can be from -128..127  (signed )

WORD can be from 0..65535 (not signed)
WORD can be from -32768..32767 (signed)

Byte and Word can never be signed. They are always unsigned types. The signed equivalents are SmallInt and ShortInt (or the other way round, I can never remember ::) ).

440bx

  • Hero Member
  • *****
  • Posts: 4194
Re: type's already defined in system.pas
« Reply #5 on: February 20, 2024, 11:45:40 pm »
The signed equivalents are SmallInt and ShortInt (or the other way round, I can never remember ::) ).
I have the same problem, can never remember which one is 8 bits and which one is 16 bits.  FPC solves that problem nicely with "int8" and "int16"... those I can "remember" ;)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

TRon

  • Hero Member
  • *****
  • Posts: 2673
Re: type's already defined in system.pas
« Reply #6 on: February 21, 2024, 12:29:47 am »
The signed equivalents are SmallInt and ShortInt (or the other way round, I can never remember ::) ).
I have the same problem, can never remember which one is 8 bits and which one is 16 bits.  FPC solves that problem nicely with "int8" and "int16"... those I can "remember" ;)
Oh, and I always thought I am the only one who can't remember those confusing integer names... Also using int8, int16, int32 and int64 here  :D

And unfortunately that kind of shite goes on and on ...  :'(
Quote
  •     On 32-bit platforms and 64-bit Windows platforms, LongWord is a 4-byte unsigned integer with the range [0 .. 4294967295] (0 through 232-1).

            Note: 32-bit platforms include 32-bit Windows, 32-bit macOS, 32-bit iOS, and Android.
  •     On 64-bit POSIX platforms (iOS and Linux), LongWord is an 8-byte unsigned integer with the range [0 .. 18446744073709551615] (0 through 264-1).

            Note: If you want to use a 4-byte unsigned integer type, use FixedUInt or Cardinal.

VisualLab

  • Sr. Member
  • ****
  • Posts: 355
Re: type's already defined in system.pas
« Reply #7 on: February 21, 2024, 12:42:42 am »
The signed equivalents are SmallInt and ShortInt (or the other way round, I can never remember ::) ).
I have the same problem, can never remember which one is 8 bits and which one is 16 bits.  FPC solves that problem nicely with "int8" and "int16"... those I can "remember" ;)

True, it's a rather unfortunate choice of names for these types. Similarly, the name "Word" has long been out of place. For some time now I have also started using aliases such as: Int8, Int16 (etc.) and UInt8, UInt16 (etc.).

P.S. I wonder if when 128-bit processors appear, the types "long long long int" and "unsigned long long long int" will appear in C and C++? Or maybe it will be LLLI and ULLLI? And it will certainly still be a "very concise and readable record" :)

And in FPC: EightWord or HexByte? :)

paule32

  • Full Member
  • ***
  • Posts: 233
Re: type's already defined in system.pas
« Reply #8 on: February 21, 2024, 01:18:05 pm »
an other funny thing:
I created a custom system.pas ...
when I try to implement the TObject class - which is defined in objpash.pas as "forward":
Code: Pascal  [Select][+][-]
  1. type
  2.     //TObject  = class;
  3.     //IUnknown = interface;
  4.  
  5.     TClass   = class of TObject;
  6.     PClass   = ^TClass;
I get Error Message:
Code: [Select]
system.pas(166,1) Error: Forward type not resolved "TObject"And when I try to implement like this forward (remember, that is Code from objpash.pas):
Code: Pascal  [Select][+][-]
  1. type
  2.     TObject  = class;
  3.     IUnknown = interface;
  4.  
  5.     TClass   = class of TObject;
  6.     PClass   = ^TClass;
I get Error Message:
Code: [Select]
system.pas(159,16) Error: Type "TObject" is not completely defined
system.pas(160,16) Error: Type "IUnknown" is not completely defined
:( :o :( :o
« Last Edit: February 21, 2024, 01:25:36 pm by paule32 »

DavidL

  • New Member
  • *
  • Posts: 10
Re: type's already defined in system.pas
« Reply #9 on: February 21, 2024, 01:35:32 pm »
The signed equivalents are SmallInt and ShortInt (or the other way round, I can never remember ::) ).
I have the same problem, can never remember which one is 8 bits and which one is 16 bits.  FPC solves that problem nicely with "int8" and "int16"... those I can "remember" ;)

True, it's a rather unfortunate choice of names for these types. Similarly, the name "Word" has long been out of place. For some time now I have also started using aliases such as: Int8, Int16 (etc.) and UInt8, UInt16 (etc.).

P.S. I wonder if when 128-bit processors appear, the types "long long long int" and "unsigned long long long int" will appear in C and C++? Or maybe it will be LLLI and ULLLI? And it will certainly still be a "very concise and readable record" :)

And in FPC: EightWord or HexByte? :)

I guess it's a good thing that machines with a "byte" size other than 8 bits have fallen away...how about a 14-bit "word" for some real fun?

I suspect C and the trash-can abomination C++ will adopt "quad int", etc. for 128-bit items.

paule32

  • Full Member
  • ***
  • Posts: 233
Re: type's already defined in system.pas
« Reply #10 on: February 21, 2024, 01:51:10 pm »
I guess it's a good thing that machines with a "byte" size other than 8 bits have fallen away...how about a 14-bit "word" for some real fun?

You can laugh now... but I thinking on packled records at the current Time...

bytebites

  • Hero Member
  • *****
  • Posts: 644
Re: type's already defined in system.pas
« Reply #11 on: February 21, 2024, 01:55:07 pm »
Completely defined
Code: Pascal  [Select][+][-]
  1. TObject  = class
  2. end;

paule32

  • Full Member
  • ***
  • Posts: 233
Re: type's already defined in system.pas
« Reply #12 on: February 21, 2024, 09:05:11 pm »
I have the following custom system.pas Code:
https://dpaste.com/44S4GWESK#line-472

This is my compile command output:
Code: [Select]
C:\lazarus\x86_64\fpc\3.2.2\bin\x86_64-win64\fpc.exe -Twin64 -Mdelphi -dwindows -dwin64 -v0 -dwindll -O2 -Os -vl -Anasmwin64 -al -FE..\..\units\fpc-sys -Us system.pas
Free Pascal Compiler version 3.2.2 [2022/09/24] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
2 202/1.248 Kb Used
100 283/1.312 Kb Used
200 328/1.312 Kb Used
300 358/1.344 Kb Used
400 401/1.376 Kb Used
system.pas(472,1) Fatal: Internal error 200305108
Fatal: Compilation aborted
Error: C:\lazarus\x86_64\fpc\3.2.2\bin\x86_64-win64\ppcx64.exe returned an error exitcode

Where is the Error Location ?

Thaddy

  • Hero Member
  • *****
  • Posts: 14614
  • Sensorship about opinions does not belong here.
Re: type's already defined in system.pas
« Reply #13 on: February 21, 2024, 09:50:00 pm »
472,1 ??
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

paule32

  • Full Member
  • ***
  • Posts: 233
Re: type's already defined in system.pas
« Reply #14 on: February 21, 2024, 09:51:45 pm »
yes.
follow the link - why is there a Error ?

 

TinyPortal © 2005-2018