WinCE / Win32 compilation

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

WinCE / Win32 compilation

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



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: WinCE / Win32 compilation

Jonas Maebe-2

On 16 Oct 2010, at 12:11, Uffe Kousgaard wrote:

> 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_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: WinCE / Win32 compilation

Uffe Kousgaard
"Jonas Maebe" <[hidden email]> wrote in
message news:[hidden email]...

> 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.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: WinCE / Win32 compilation

Sven Barth-2
On 16.10.2010 12:35, Uffe Kousgaard wrote:

> "Jonas Maebe"<[hidden email]>  wrote in
> message news:[hidden email]...
>
>> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Re: WinCE / Win32 compilation

Uffe Kousgaard
"Sven Barth" <[hidden email]> 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.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Re: WinCE / Win32 compilation

Matt Emson-2
On 16 Oct 2010, at 14:23, "Uffe Kousgaard" <[hidden email]> wrote:

> "Sven Barth" <[hidden email]> 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_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal