Sign in Join

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

Mailing lists / fpc-pascal / 2021-10

String error on Windows

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Hairy Pixels

Why isn't this syntax valid on Windows? Very confused.

============================

{$mode objfpc}
program WindowsTest;
var
s: String;
begin
s += ';';    //  Syntax error, ";" expected but "const char" found
end.

Reply by email

Alexander Grotewohl
to Hairy Pixels

Because += is a mistake and hopefully it's irreparably broken.

Does using just s:=s+';'; work?
Alexander Grotewohl https://dcclost.com ________________________________
Earlier message 19 lines
From: fpc-pascal on behalf of Hairy Pixels via fpc-pascal Sent: Saturday, October 30, 2021 11:09:49 PM To: FPC-Pascal users discussions Cc: Hairy Pixels Subject: [fpc-pascal] String error on Windows Why isn't this syntax valid on Windows? Very confused. ============================ {$mode objfpc} program WindowsTest; var s: String; begin s += ';'; // Syntax error, ";" expected but "const char" found end.

Reply by email

Ryan Joseph
to Alexander Grotewohl
Show quoted text 6 lines
On Oct 31, 2021, at 10:50 AM, Alexander Grotewohl via fpc-pascal wrote: Because += is a mistake and hopefully it's irreparably broken. Does using just s:=s+';'; work?

I thought they were behind a mode switch called "c operators" or something but either way I don't see why Windows would disable them. They're all over my program which runs on macOS and I don't want to remove them (like that operator myself).

Regards,
Ryan Joseph

Reply by email

Jonas Maebe
to Ryan Joseph
Ryan Joseph wrote
I thought they were behind a mode switch called "c operators" or something but either way I don't see why Windows would disable them.

The compiler itself does enable them by the default on any platform. However, the fpc.cfg file that gets installed with FPC on all platforms does enable them by default (it contains -Sgic). Compile with -vt and check where the compiler is getting its configuration file from.

Jonas

Reply by email

Sven Barth
to Jonas Maebe

Jonas Maebe via fpc-pascal schrieb am
So., 31. Okt. 2021, 08:54:

Show quoted text 5 lines
On 31/10/2021 05:35, Ryan Joseph via fpc-pascal wrote: > I thought they were behind a mode switch called "c operators" or something but either way I don't see why Windows would disable them. The compiler itself does enable them by the default on any platform.

Jonas means "does NOT enable" here.

However, the fpc.cfg file that gets installed with FPC on all platforms does enable them by default (it contains -Sgic). Compile with -vt and check where the compiler is getting its configuration file from.

Regards,
Sven

Reply by email

Ryan Joseph
to Jonas Maebe: The compiler itself does enable them by the default on any platform. However, the fpc.cfg…
On Oct 31, 2021, at 2:53 PM, Jonas Maebe via fpc-pascal wrote: The compiler itself does enable them by the default on any platform. However, the fpc.cfg file that gets installed with FPC on all platforms does enable them by default (it contains -Sgic). Compile with -vt and check where the compiler is getting its configuration file from.

Thanks, I see -Sc now but I've always taken for granted it was always there. What confused me is that it's a command line option instead of a mode switch like other language features.

Regards,
Ryan Joseph

Reply by email

Sven Barth
to Ryan Joseph
Ryan Joseph wrote 5 lines
> On Oct 31, 2021, at 2:53 PM, Jonas Maebe via fpc-pascal wrote: > > The compiler itself does enable them by the default on any platform. However, the fpc.cfg file that gets installed with FPC on all platforms does enable them by default (it contains -Sgic). Compile with -vt and check where the compiler is getting its configuration file from. Thanks, I see -Sc now but I've always taken for granted it was always there. What confused me is that it's a command line option instead of a mode switch like other language features.

It's simply a separate directive: $COperators. The advantage of having it (and some others) separate is that any mode directive in the source will reset any modeswitches that were set on the command line.

Regards,
Sven

Reply by email