Recent

Author Topic: FPC 3.2.2 - non Alpha Names of Classes and Members - possible ?  (Read 806 times)

paule32

  • Hero Member
  • *****
  • Posts: 603
  • One in all. But, not all in one.
Hello,
Is it possible to give the Class's and Member's of a Class different Names with non-alpha Values (Char's) ?
How can I do this in the source code ?
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

PascalDragon

  • Hero Member
  • *****
  • Posts: 6049
  • Compiler Developer
Re: FPC 3.2.2 - non Alpha Names of Classes and Members - possible ?
« Reply #1 on: July 03, 2025, 09:18:21 pm »
No, it's not possible.

Khrys

  • Sr. Member
  • ****
  • Posts: 259
Re: FPC 3.2.2 - non Alpha Names of Classes and Members - possible ?
« Reply #2 on: July 04, 2025, 07:16:03 am »
Like @PascalDragon said, it's not possible. Only strings matching  &?[^\W\d]\w*  can be identifiers.

You can prefix any identifier with a single  &  (for example to allow using keywords that are otherwise reserved, e.g.  var &Type: Char), so technically speaking there can be non-alphanumeric characters in the source describing an identifier, although this prefix is ignored in later compilation stages  —  e.g.  var A, &A: Integer  will generate a "duplicate identifier" error.

paule32

  • Hero Member
  • *****
  • Posts: 603
  • One in all. But, not all in one.
Re: FPC 3.2.2 - non Alpha Names of Classes and Members - possible ?
« Reply #3 on: July 04, 2025, 08:30:33 am »
for some month's ago, I used objdump.exe to rename Symbols.
I don't remember me on the Details.
But with this Tool, I could do rename DLL Symbols.
If it possible with .o files - I don't know.
Yet.
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

Khrys

  • Sr. Member
  • ****
  • Posts: 259
Re: FPC 3.2.2 - non Alpha Names of Classes and Members - possible ?
« Reply #4 on: July 04, 2025, 10:24:16 am »
for some month's ago, I used objdump.exe to rename Symbols.

Classes and class members aren't symbols, so that won't help.

Perhaps what you're really after is renaming symbols of class methods, e.g.  CLASSES$_$TSTREAM_$__$$_COPYFROM$TSTREAM$INT64$$INT64  ?

paule32

  • Hero Member
  • *****
  • Posts: 603
  • One in all. But, not all in one.
Re: FPC 3.2.2 - non Alpha Names of Classes and Members - possible ?
« Reply #5 on: July 04, 2025, 02:15:06 pm »
when I do so with the Assembly Code, then I stuck in trouble with linking into a executable.
The Problem is not createing the Assembly Code, and compile to .o bject File(s).
The Problem is, that I don't know, how FPC link the .o bjects to an Executable.

FPC provide some Linker Scripts and Batch Files by given Command Line Options.
But when I execute the Batch Files, that contains Code/Commands to link the produces binaries to an Executable, some Magic opens and bring my mind flattered.

Maybe I should compile the .asm Files in a pre-task, before I include the .o in the Sources and then call FPC to link the Files to an Executable.
This could work.
But I don't let it a try, yet.

But I can looking forward, that could be not easy.
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

PascalDragon

  • Hero Member
  • *****
  • Posts: 6049
  • Compiler Developer
Re: FPC 3.2.2 - non Alpha Names of Classes and Members - possible ?
« Reply #6 on: July 06, 2025, 03:10:48 pm »
You can prefix any identifier with a single  &  (for example to allow using keywords that are otherwise reserved, e.g.  var &Type: Char), so technically speaking there can be non-alphanumeric characters in the source describing an identifier, although this prefix is ignored in later compilation stages  —  e.g.  var A, &A: Integer  will generate a "duplicate identifier" error.

This is only an escape token, not a part of the identifier.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8453
Re: FPC 3.2.2 - non Alpha Names of Classes and Members - possible ?
« Reply #7 on: July 07, 2025, 01:29:04 pm »
for some month's ago, I used objdump.exe to rename Symbols.
I don't remember me on the Details.
But with this Tool, I could do rename DLL Symbols.
If it possible with .o files - I don't know.
Yet.

Bottom line: class and member names have to be valid Pascal identifiers.

If you have some very specific reason why they should not be, or where the external name should be presented with capitalisation other than the current convention, or where an exported identifier should have a different compiler-generated separator, then discussion might possibly be in the scope of this forum.

If you have a specific hack using external tools which allows you to use FPC-generated .so or .dll files in the context of some other language (or vice versa), or to tidy things up for a non-standard debugger, then getting it into the record is probably in the scope of this forum.

But I suggest that FPC's limited compatibility with C++ etc. and the private nature of member names etc. means that you must expect an uphill struggle if you're proposing any changes.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018