Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread noreply

On 2017-08-27 21:12, Paulo Costa wrote:

On 27-Aug-17 23:47, Dmitry Boyarintsev wrote:

Is 2 neither true, nor false? 3? 4?

If false is zero,
Then true is not false.

Also C doesn't have a boolean type per se. Iirc it was introduced in 
some version of c++ standard.


In C it's very strange to see code like that:

If (b==1)

It's always
If (b)
Or
If (!b)


Of course, that is because, in C, any value that is not zero, is true.

So you can not compare with 1 or -1 or any other value to test if it is 
true...


Paulo Costa


There were some very rare edge cases, that occur, though, I have heard, 
where... this is not the case.


But I would have to take the time to look up the article where I found 
this...


It could even be a rumor, but I think it is serious..

Since it is an edge case, it creeps in like sh*t when you don't expect 
it.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread Paulo Costa

On 27-Aug-17 23:47, Dmitry Boyarintsev wrote:

Is 2 neither true, nor false? 3? 4?

If false is zero,
Then true is not false.

Also C doesn't have a boolean type per se. Iirc it was introduced in 
some version of c++ standard.


In C it's very strange to see code like that:

If (b==1)

It's always
If (b)
Or
If (!b)


Of course, that is because, in C, any value that is not zero, is true.

So you can not compare with 1 or -1 or any other value to test if it is 
true...


Paulo Costa
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread Dmitry Boyarintsev
Is 2 neither true, nor false? 3? 4?

If false is zero,
Then true is not false.

Also C doesn't have a boolean type per se. Iirc it was introduced in some
version of c++ standard.

In C it's very strange to see code like that:

If (b==1)

It's always
If (b)
Or
If (!b)



On Sunday, August 27, 2017,  wrote:

> On 2017-08-27 06:22, Dmitry Boyarintsev wrote:
>
>> On Sun, Aug 27, 2017 at 2:37 AM,  wrote:
>>
>> Why borland chose the bool to not be 100 percent compatible, and
>>> only 50 percent compatible?
>>>
>>> Bool in delphi:
>>> true = -1
>>>
>>> Bool in C:
>>> true = ($)  1
>>>
>>> Why not just make it exactly compatible, there must be some
>>> underlying (possibly obnoxious) reason for this mess.
>>>
>>
>> They are compatible, if you declare like this:
>>
>> true = (not false);
>>
>>
> Depends, AFAIK, if the C library checks for an exact value of 1 somewhere,
> when Delphi/FPC sends in a -1, this could cause problems, but I haven't
> thought about it enough.
>
> I just don't see why both languages could not just agree to use "1", they
> must have had some reason, strange or not.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Freepascal Floating Point Issue

2017-08-27 Thread Ched

Hello,

I agree that the extended type is not portable and not as fast as double.

But sometimes, we absolutely need numerical precision, so we have to assume the costs in terms of runtime 
and possibly nonportability. When the algorithms are nearly optimal, there is no room for software 
enhancement. So, the programmers, not the OS makers !, has to do the choices about accuracy, runtime and 
hardware configuration. For my numerical problems, I absolutely need "full" extended, not just doubles.


As the 18-19 digits extended type is availables in Freepascal for the common Intel processors, I don't 
understand why we will have no more the right to use it under x64 OS...


Cheers, Ched



Le 25.08.2017 à 08:08, Michael Schnell a écrit :

On 25.08.2017 01:32, Ralf Quint wrote:


It's not a problem of "modern" Windows, but a problem of any 64bit x86
OS

Supposedly of (m)any non-x64 archs as well.

Hence relying on "extended" is not portable.

-Michael


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread noreply

On 2017-08-27 06:22, Dmitry Boyarintsev wrote:

On Sun, Aug 27, 2017 at 2:37 AM,  wrote:


Why borland chose the bool to not be 100 percent compatible, and
only 50 percent compatible?

Bool in delphi:
true = -1

Bool in C:
true = ($)  1

Why not just make it exactly compatible, there must be some
underlying (possibly obnoxious) reason for this mess.


They are compatible, if you declare like this:

true = (not false);



Depends, AFAIK, if the C library checks for an exact value of 1 
somewhere, when Delphi/FPC sends in a -1, this could cause problems, but 
I haven't thought about it enough.


I just don't see why both languages could not just agree to use "1", 
they must have had some reason, strange or not.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] sending new parameters to existing instance

2017-08-27 Thread noreply

On 2017-08-27 14:52, James Richters wrote:
i think you're looking for IPC (InterProcess Communication)... with 
this, the second instance would load up, find that there is one 
already running, tell the already running one about the new file to 
load, and then exit...


Thank you, that is exactly what I want but did not know what it was 
called.


James



http://wiki.lazarus.freepascal.org/SimpleIPC

FPC has its own ipc unit that makes it pretty easy, and I ported it to a 
DLL so that any program in any language can communicate with an fpc 
program

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread noreply

On 2017-08-27 12:25, mar...@stack.nl wrote:

In our previous episode, nore...@z505.com said:

> rarer
> cases)

That's good news, does Delphi need to add a boolean8/16/32 some day, 
or

already has?


I don't know. FPC needed it for GTK interfacing, but FPC doesn't use 
it.


The main headers interfaced by Delphi are WINAPI, and they have 
longbool.



As I often switch between using fpc and delphi all the time, almost
50/50


More importantly, if you still use ancient D7, would you actually buy a 
new

version (for Eur 1500 or so) if they added it ?



I use ancient versions (D5 and D7) but also have purchased the latest 
Tokyo and use latest too..


No I would not buy it just for that, but, I wonder if I should ring them 
an email on their quality central and feature request it, if they 
haven't got that figured out yet. This header translation stuff, is 
still bothering us years later since the 1990's already, and many errors 
in programs exist because of these damn headers that aren't perfectly 
translated ;-(

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread Sven Barth via fpc-pascal
On 27.08.2017 19:27, Marco van de Voort wrote:
> In our previous episode, Sven Barth via fpc-pascal said:
>> Am 27.08.2017 00:10 schrieb "Marco van de Voort" :
>>> The GTK headers also use a 0/1 boolean, and for that the boolean8/16/32
>>> types were created. I couldn't quickly find docs, so I filed a bug for
>> that.
>>
>> Please note that there is no Boolean8 as that one is simply Boolean. But
>> there is also a Boolean64 and QWordBool ;)
> 
> Boolean can be packed in ISO mode, Boolean8 has an explicit size so
> shouldn't :-)

Even the Boolean16/32/64 types are bitpacked down to one bit, so that's
definitely no reason :P

> Seriously, without searching for something pedantic to say, I thought that
> an alias was added for orthogonality. Maybe it should.

*shrugs* If you think so...

Regards,
Sven

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] sending new parameters to existing instance

2017-08-27 Thread James Richters
>i think you're looking for IPC (InterProcess Communication)... with this, the 
>second instance would load up, find that there is one already running, tell 
>the already running one about the new file to load, and then exit...

Thank you, that is exactly what I want but did not know what it was called.

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread Marco van de Voort
In our previous episode, Sven Barth via fpc-pascal said:
> Am 27.08.2017 00:10 schrieb "Marco van de Voort" :
> > The GTK headers also use a 0/1 boolean, and for that the boolean8/16/32
> > types were created. I couldn't quickly find docs, so I filed a bug for
> that.
> 
> Please note that there is no Boolean8 as that one is simply Boolean. But
> there is also a Boolean64 and QWordBool ;)

Boolean can be packed in ISO mode, Boolean8 has an explicit size so
shouldn't :-)

Seriously, without searching for something pedantic to say, I thought that
an alias was added for orthogonality. Maybe it should.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread Marco van de Voort
In our previous episode, nore...@z505.com said:
> > rarer
> > cases)
> 
> That's good news, does Delphi need to add a boolean8/16/32 some day, or 
> already has?

I don't know. FPC needed it for GTK interfacing, but FPC doesn't use it.

The main headers interfaced by Delphi are WINAPI, and they have longbool.
 
> As I often switch between using fpc and delphi all the time, almost 
> 50/50

More importantly, if you still use ancient D7, would you actually buy a new
version (for Eur 1500 or so) if they added it ?

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread Marco van de Voort
In our previous episode, nore...@z505.com said:
> > And sometimes API don't adhere to above statement, and then having 
> > chosen
> > the right boolean type (longbool or boolean) saves a lot of trouble.
> 
> Another option is to write BOOLEAN wrappers around the lower level 
> functions that interface in to the DLL
> So for example, could even use an INTEGER, as the boolean, as the Jedi 
> fellow sometimes does, then write a wrapper around it that makes use of 
> a proper boolean. All this, though, is a headache and obnoxious, tedious 

I think doing this systematically introduces more mistakes than it solves,
since all that manual work also has a risk at errors.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] sending new parameters to existing instance

2017-08-27 Thread wkitty42

On 08/27/2017 12:18 PM, James Richters wrote:

I have a windows console application I wrote with Freepascal.I can send
it a command line parameter for a file to use have it working so if I just
double click on the file I wish to open with my program, it launches and
opens it.   I am wondering how I can set it up so that double clicking a
second file will just load the new file into the first instance instead of
opening a second instance of the program.   I've been thinking up schemes for
how this could be done, but I think there must be some system in place that
does this already because a lot windows programs behave this way, just
loading the new file into the existing instance, but I'm not familiar enough
with how this is done.   Could someone please point me in the right direction
on how this is typically done?


i think you're looking for IPC (InterProcess Communication)... with this, the 
second instance would load up, find that there is one already running, tell the 
already running one about the new file to load, and then exit...



--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list unless*
   *a signed and pre-paid contract is in effect with us.*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] sending new parameters to existing instance

2017-08-27 Thread James Richters
I have a windows console application I wrote with Freepascal.I can send it 
a command line parameter for a file to use have it working so if I just double 
click on the file I wish to open with my program, it launches and opens it.   I 
am wondering how I can set it up so that double clicking a second file will 
just load the new file into the first instance instead of opening a second 
instance of the program.   I've been thinking up schemes for how this could be 
done, but I think there must be some system in place that does this already 
because a lot windows programs behave this way, just loading the new file into 
the existing instance, but I'm not familiar enough with how this is done.   
Could someone please point me in the right direction on how this is typically 
done?

James


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread Dmitry Boyarintsev
On Sun, Aug 27, 2017 at 2:37 AM,  wrote:

>
> Why borland chose the bool to not be 100 percent compatible, and only 50
> percent compatible?
>
> Bool in delphi:
> true = -1
>
> Bool in C:
> true = ($)  1
>
> Why not just make it exactly compatible, there must be some underlying
> (possibly obnoxious) reason for this mess.


They are compatible, if you declare like this:
true = (not false);

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread Sven Barth via fpc-pascal
Am 27.08.2017 00:10 schrieb "Marco van de Voort" :
> The GTK headers also use a 0/1 boolean, and for that the boolean8/16/32
> types were created. I couldn't quickly find docs, so I filed a bug for
that.

Please note that there is no Boolean8 as that one is simply Boolean. But
there is also a Boolean64 and QWordBool ;)

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread noreply

On 2017-08-26 17:09, mar...@stack.nl wrote:

In our previous episode, nore...@z505.com said:

But it gets worse than that: even fpc/delphi's bool is not always
compatible (but is sometimes).

For example:
http://blog.delphi-jedi.net/2008/09/25/bool-boolean-and-integer/

When one must use Integers to do boolean related programming tasks, it
makes me want to quit programming ;)


The QueryServiceConfig2 is a known exception in WINAPI land that in 
some

cases assumes things about what is TRUE.

The GTK headers also use a 0/1 boolean, and for that the boolean8/16/32
types were created. I couldn't quickly find docs, so I filed a bug for 
that.


IOW that problem has long resolved, you just need to know what 
convention
the C code uses, and map that then to either boolean32 or longbool (or 
rarer

cases)


That's good news, does Delphi need to add a boolean8/16/32 some day, or 
already has?


As I often switch between using fpc and delphi all the time, almost 
50/50

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread noreply

On 2017-08-26 17:22, mar...@stack.nl wrote:

In our previous episode, Michael Van Canneyt said:
I think the programmer *must* worry about the details and must 
definitely

NOT use the booleans for anything C related. That was my point.


The interface uses bool, either as param or in a structure. So what can 
you

do?

Attempting to cater for C code using BOOL or whatever type is 
misplaced.

C does not have a boolean type.


Since C99 it has:

https://stackoverflow.com/questions/4767923/c99-boolean-data-type


The standard says for "if" :

"In both forms, the first substatement is executed if the expression
compares unequal to 0."

Treat it as such.


All true, but futile, since one assumes the C side is not written by 
whoever

wants to interface it. He might not even have source.

And sometimes API don't adhere to above statement, and then having 
chosen

the right boolean type (longbool or boolean) saves a lot of trouble.


Another option is to write BOOLEAN wrappers around the lower level 
functions that interface in to the DLL
So for example, could even use an INTEGER, as the boolean, as the Jedi 
fellow sometimes does, then write a wrapper around it that makes use of 
a proper boolean. All this, though, is a headache and obnoxious, tedious 
.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-27 Thread noreply

On 2017-08-26 02:50, Michael Van Canneyt wrote:
I thought all this BOOL mess was just meant to be able to interface 
with C

libs slightly easier.


But, why is the BOOL in fpc/delphi not compatible with C BOOL, in that 
it has different semantics?


One value lines up correct... but not always the other.

Why borland chose the bool to not be 100 percent compatible, and only 50 
percent compatible?


Bool in delphi:
true = -1

Bool in C:
true = ($)  1

Why not just make it exactly compatible, there must be some underlying 
(possibly obnoxious) reason for this mess.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal