Sign in Join

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

Mailing lists / fpc-pascal / 2010-10

WinCE / Win32 compilation

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Uffe Kousgaard

I am still compiling delphi code and do now compile for both win32 and winCE. WinCE works (but executable untested), while win32 complains a few places:

1) Whenever I compile "single = min(single,single)" I have to add math.min or the win32 compiler complains and expects longints instead. Is there a difference between the RTL in the two versions?

I have not been able to setup a small example, showing this. Unfortunately.

Max function has the same issue.

2) I use TCriticalsection, but get this message: Error: Unknown record field identifer "Create". I get similar error when calling enter, leave or free methods.

This one stops me at the moment.

TIA
Uffe Kousgaard

Jonas Maebe
to Uffe Kousgaard
Uffe Kousgaard wrote 7 lines
I am still compiling delphi code and do now compile for both win32 and winCE. WinCE works (but executable untested), while win32 complains a few places: 1) Whenever I compile "single = min(single,single)" I have to add math.min or the win32 compiler complains and expects longints instead. Is there a difference between the RTL in the two versions?

Compile with -vh to see which declaration the compiler finds when the compilation fails.

2) I use TCriticalsection, but get this message: Error: Unknown record field identifer "Create". I get similar error when calling enter, leave or free methods.

TCriticicalSection is not a class, it's a Win API struct. You have to use Windows.InitCriticalSection and friends to work with it. There's also TRTLCriticalSection, which works with System.InitCriticalSection and friends.

Jonas

Uffe Kousgaard
to Jonas Maebe

"Jonas Maebe" wrote in
message

Show quoted text 6 lines
1) Whenever I compile "single = min(single,single)" I have to add math.min or the win32 compiler complains and expects longints instead. Is there a difference between the RTL in the two versions? Compile with -vh to see which declaration the compiler finds when the compilation fails.

Max(LongInt,LongInt): LongInt

TCriticalSection is not a class, it's a Win API struct.

It is a class in D7, SyncObjs.pas. And understood by the WinCE compiler, at least it seems so.

Even if it just maps to the WinAPI, it is still a class.

Sven Barth
to Uffe Kousgaard
Uffe Kousgaard wrote 18 lines
"Jonas Maebe" wrote in message > 1) Whenever I compile "single = min(single,single)" I have to add math.min > or the win32 compiler complains and expects longints instead. Is there a > difference between the RTL in the two versions? > Compile with -vh to see which declaration the compiler finds when the > compilation fails. Max(LongInt,LongInt): LongInt > TCriticalSection is not a class, it's a Win API struct. It is a class in D7, SyncObjs.pas. And understood by the WinCE compiler, at least it seems so. Even if it just maps to the WinAPI, it is still a class.

TCriticalSection is a WinAPI struct if you include the unit Windows. If you include the unit SyncObjs it's a Object Pascal class that uses FPC's cross platform TRTLCriticalSection.

The problem is if you include both units it depends on the order of the unit which type wins.

E.g.

uses
   Windows, SyncObjs;
var
   cs: TCriticalSection; // will be SyncObjs.TCriticalSection (a class)

but

uses
   SyncObjs, Windows;
var
   cs: TCriticalSection; // will be Windows.TCriticalSection (a record)

This is the same in Delphi by the way.

Regards,
Sven

Uffe Kousgaard
to Sven Barth

"Sven Barth" wrote in
message

TCriticalSection is a WinAPI struct if you include the unit Windows.

OK, that explains. In Delphi the WinAPI struct is called TRTLCriticalSection. So, no name clashing.

Matt Emson
to Uffe Kousgaard
"Uffe Kousgaard" wrote
"Sven Barth" wrote in message > > TCriticalSection is a WinAPI struct if you include the unit Windows.

Appart from unit ordering (which is a shaky way of reliably resolving things), you could always qualify the name with the unit prefix too:

var cs: SyncObjs.TCriticalSection;

This would universally work across Delphi and FPC and unit order would not matter.

Sent from my iPhone