Sign in Join

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

Mailing lists / fpc-pascal / 2010-01

different windows/linux behavior with enumerated types and write/writeln

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Seth Grover

If I have a program like this:

------------------------------------------------------
program Project1;
{$mode objfpc}{$H+}
type
  whatever = (seth, paul, ken);
var
  haha : whatever;
begin
  haha := seth;
  writeln(haha);
end.
------------------------------------------------------

I can compile it in linux with FPC and run it and get the following output:

------------------------------------------------------ $ ./project1
seth
------------------------------------------------------

In other words, it actually prints out the name of the enumerated value.

In windows the program does not compile with an error of "Error: Can't read or write variables of this type".

Why the difference in behavior?

-SG

This email is fiction. Any resemblance to actual events or persons living or dead is purely coincidental. Seth Grover sethdgrover[at]gmail[dot]com
Jonas Maebe
to Seth Grover
Seth Grover wrote 6 lines
In other words, it actually prints out the name of the enumerated value. In windows the program does not compile with an error of "Error: Can't read or write variables of this type". Why the difference in behavior?

Different compiler version. The above is only possible as of 2.4.0.

Jonas

Marco van de Voort
to Jonas Maebe

In our previous episode, Jonas Maebe said:

Show quoted text 8 lines
> In other words, it actually prints out the name of the enumerated value. > > In windows the program does not compile with an error of "Error: Can't > read or write variables of this type". > > Why the difference in behavior? Different compiler version. The above is only possible as of 2.4.0.

(as confirmation:

C:\>fpc test.pp
Free Pascal Compiler version 2.4.0 [2009/12/18] for i386 Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Win32 for i386
Compiling test.pp
Linking test.exe
12 lines compiled, 0.3 sec , 26912 bytes code, 1640 bytes data

C:\>test
seth

C:\>