Re: [fpc-pascal] Cannot write datetime field on sqlite3 database on ARM

2021-03-09 Thread Florian Klämpfl via fpc-pascal


> Am 10.03.2021 um 04:59 schrieb Toru Takubo via fpc-pascal 
> :
> 
>> Can you please post the output of -va of the arm compiler and provide some 
>> information about the arm system you are using?
> 
> The output message with -va option can be downloaded from below.
> 
> http://support.e-parcel.ne.jp/downloads/tmp/fpc-va.txt
[0.016] (3101) Macro defined: CPUARMV4
[0.016] (3101) Macro defined: FPUFPA
I am not sure how this happened but you are compiling for an ancient arm 
architecture, this is not going to work. FPA uses a different floating point 
format so this explains the problems.

> 
> Target machine is Raspberry Pi OS on Raspberry Pi 3 Model B V1.2.
> 
> # uname -a
> Linux raspberrypi 5.4.51-v7+ #1327 SMP Thu Jul 23 10:58:46 BST 2020 armv7l 
> GNU/Linux
> 
> Best Regards,
> 
> Toru
> 
> 
> 
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Cannot write datetime field on sqlite3 database on ARM

2021-03-09 Thread LacaK via fpc-pascal


Dňa 9.3.2021 o 15:34 Toru Takubo via fpc-pascal napísal(a):

On 2021/03/09 18:11, LacaK via fpc-pascal wrote:
I did run test program on RaspberryPI: Linux+ARM and results are as 
expected.

(FPC 3.2.0)

-Laco.

Thank you for your reproduction test. It may be a good news that the 
problem would

not be in the compiler but around configuration or environment.

Do you have a native compiler on RaspberryPI, or using cross compiler?


I am using cross compiler. (build by FpcUpDeluxe)



My compiler setting is below. Does something missing or wrong?


My settings are:

-Tlinux
-Parm
-MObjFPC
-Scghi
-O1
-g
-gl
-l
-vewnhibq
-Filib\arm-linux
-Fu.
-FUlib\arm-linux
-FE.
-oproject1



---
C:\lazarus\fpc\3.2.0\bin\i386-win32\fpc.exe
-Tlinux
-Parm
-MObjFPC
-Sh
-CX
-O3
-XX
-l
-vewnibq
-vh-
-vm5057,5028,5024,3042
-Fiobj\arm-linux
-Fu.
-FEobj\arm-linux
-oobj\arm-linux\project1
---

If possible, would you publish your executive of the test program to 
try it?


Uploaded to 
http://moja.uschovna.zoznam.sk/link/af6c3620-b919-4d64-9ab4-978af3d84717


-Laco.


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


Re: [fpc-pascal] Cannot write datetime field on sqlite3 database on ARM

2021-03-09 Thread Toru Takubo via fpc-pascal

On 2021/03/10 5:40, Florian Klämpfl via fpc-pascal wrote:

Am 09.03.21 um 01:47 schrieb Toru Takubo via fpc-pascal:

On 2021/03/08 16:54, Michael Van Canneyt via fpc-pascal wrote:



On Mon, 8 Mar 2021, Toru Takubo via fpc-pascal wrote:


Hi,

I am developing my app on Windows and building apps for other
platforms by using cross compiler. Now I have a problem only
occurred on Linux ARM.

The problem is that it cannot write datetime field on sqlite3
database. It can read/write other fields like int, varchar
or blob, but always write zero in datetime (maybe float as well)
field.

Does anyone have an idea about this issue? I am not sure it is
fpc issue, but better to report bug?


It sounds like a floating point problem. As you probably know, a TDateTime
type is actually a double type. Did you try with a float value ?

The DB explorer tools probably just use strings to read/write from the
database, so they will not be bothere by such things, but FPC stores dataset
values in 'native' formats in memory.

I don't know what to advise to further investigate the issue, One thing to
try would be to test whether normal float arithmetic or date arithmetic works.
If not, then the compiler people will need to give more advice.



I created a simple test code, and ran on linux-i386 and linux-arm.


Can you please post the output of -va of the arm compiler and provide some 
information about the arm system you are using?


The output message with -va option can be downloaded from below.

http://support.e-parcel.ne.jp/downloads/tmp/fpc-va.txt

Target machine is Raspberry Pi OS on Raspberry Pi 3 Model B V1.2.

# uname -a
Linux raspberrypi 5.4.51-v7+ #1327 SMP Thu Jul 23 10:58:46 BST 2020 armv7l 
GNU/Linux

Best Regards,

Toru




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


Re: [fpc-pascal] Unicode chars losing information

2021-03-09 Thread Michael Van Canneyt via fpc-pascal



On Tue, 9 Mar 2021, Florian Klämpfl via fpc-pascal wrote:


By using the necessary IFDEF mechanism in the config file, we can avoid
inserting it for windows (which does not need it) or the smaller embedded 
platforms
(which cannot handle it).

People that don't need/want this can remove the config setting from the file. 
All the others leave it as-is and will get their desired conversion mechanisms
'for free'.

This way a default choice is made for you on those platforms, but you can still 
100% control
it.


I am very much against this because this means that a default FPC
executable would link against libc.  And this is far too much only because
a few people complain because they didn’t read the docs.


Well, maybe the Lazarus IDE can insert the necessary units, just like it is
done for cthreads...

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


Re: [fpc-pascal] Cannot write datetime field on sqlite3 database on ARM

2021-03-09 Thread Florian Klämpfl via fpc-pascal

Am 09.03.21 um 01:47 schrieb Toru Takubo via fpc-pascal:

On 2021/03/08 16:54, Michael Van Canneyt via fpc-pascal wrote:



On Mon, 8 Mar 2021, Toru Takubo via fpc-pascal wrote:


Hi,

I am developing my app on Windows and building apps for other
platforms by using cross compiler. Now I have a problem only
occurred on Linux ARM.

The problem is that it cannot write datetime field on sqlite3
database. It can read/write other fields like int, varchar
or blob, but always write zero in datetime (maybe float as well)
field.

Does anyone have an idea about this issue? I am not sure it is
fpc issue, but better to report bug?


It sounds like a floating point problem. As you probably know, a 
TDateTime

type is actually a double type. Did you try with a float value ?

The DB explorer tools probably just use strings to read/write from the
database, so they will not be bothere by such things, but FPC stores 
dataset

values in 'native' formats in memory.

I don't know what to advise to further investigate the issue, One 
thing to
try would be to test whether normal float arithmetic or date 
arithmetic works.

If not, then the compiler people will need to give more advice.



I created a simple test code, and ran on linux-i386 and linux-arm.


Can you please post the output of -va of the arm compiler and provide 
some information about the arm system you are using?

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


Re: [fpc-pascal] Unicode chars losing information

2021-03-09 Thread Florian Klämpfl via fpc-pascal


> Am 09.03.2021 um 10:06 schrieb Michael Van Canneyt via fpc-pascal 
> :
> 
> 
> 
>> On Tue, 9 Mar 2021, Graeme Geldenhuys via fpc-pascal wrote:
>> 
>>> On 09/03/2021 1:44 am, Tomas Hajny via fpc-pascal wrote:
>>> UnicodeString may be used in a program simply because the included unit has 
>>> it used in its interface. That may be the case even if there's no use of 
>>> characters outside of US ASCII at all.
>> 
>> So FPC rather goes with the fact that data may be *silently* lost during
>> encoding conversions? That doesn't seem like a safe default behaviour to
>> me.
> 
> No, we give the programmer a choice: * Not use unicode conversion at all.
> * Use the C library to handle conversion (cwstring).
> * Use FPC native code to handle conversion (fpwidestring).
> * Some other means.
> 
> Since the compiler cannot reliably detect that a choice was made, it also 
> cannot make the choice for you, because the choice also cannot be undone by 
> the compiler.
> 
> This mechanism implies the programmer *has* to make that choice.
> 
> This is not different from the threading driver mechanism, for which Lazarus 
> adds
> some {$IFDEF } mechanisms in the program uses clause.
> 
> But, I have been thinking about this. What we can do to alleviate this is the 
> following:
> 
> Use the -FaNNN option of the command line.
> 
> This option will insert NNN implicitly in the uses clause of the program.
> 
> So, we can add -Fafpwidestring
> or
> -Facwstring
> 
> in the default generated fpc.cfg config file for selected platforms (mac, 
> linux
> i386,64-bit, *bsd). The result will be that a widestring driver unit will be 
> inserted by default for those platforms.
> 
> By using the necessary IFDEF mechanism in the config file, we can avoid
> inserting it for windows (which does not need it) or the smaller embedded 
> platforms
> (which cannot handle it).
> 
> People that don't need/want this can remove the config setting from the file. 
> All the others leave it as-is and will get their desired conversion mechanisms
> 'for free'.
> 
> This way a default choice is made for you on those platforms, but you can 
> still 100% control
> it.

I am very much against this because this means that a default FPC executable 
would link against libc. And this is far too much only because a few people 
complain because they didn’t read the docs.

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


Re: [fpc-pascal] Cannot write datetime field on sqlite3 database on ARM

2021-03-09 Thread Toru Takubo via fpc-pascal

On 2021/03/09 18:11, LacaK via fpc-pascal wrote:

I did run test program on RaspberryPI: Linux+ARM and results are as expected.
(FPC 3.2.0)

-Laco.


Thank you for your reproduction test. It may be a good news that the problem 
would
not be in the compiler but around configuration or environment.

Do you have a native compiler on RaspberryPI, or using cross compiler?
My compiler setting is below. Does something missing or wrong?
---
C:\lazarus\fpc\3.2.0\bin\i386-win32\fpc.exe
-Tlinux
-Parm
-MObjFPC
-Sh
-CX
-O3
-XX
-l
-vewnibq
-vh-
-vm5057,5028,5024,3042
-Fiobj\arm-linux
-Fu.
-FEobj\arm-linux
-oobj\arm-linux\project1
---

If possible, would you publish your executive of the test program to try it?

Toru


Dňa 9.3.2021 o 1:47 Toru Takubo via fpc-pascal napísal(a):

On 2021/03/08 16:54, Michael Van Canneyt via fpc-pascal wrote:



On Mon, 8 Mar 2021, Toru Takubo via fpc-pascal wrote:


Hi,

I am developing my app on Windows and building apps for other
platforms by using cross compiler. Now I have a problem only
occurred on Linux ARM.

The problem is that it cannot write datetime field on sqlite3
database. It can read/write other fields like int, varchar
or blob, but always write zero in datetime (maybe float as well)
field.

Does anyone have an idea about this issue? I am not sure it is
fpc issue, but better to report bug?


It sounds like a floating point problem. As you probably know, a TDateTime
type is actually a double type. Did you try with a float value ?

The DB explorer tools probably just use strings to read/write from the
database, so they will not be bothere by such things, but FPC stores dataset
values in 'native' formats in memory.

I don't know what to advise to further investigate the issue, One thing to
try would be to test whether normal float arithmetic or date arithmetic works.
If not, then the compiler people will need to give more advice.



I created a simple test code, and ran on linux-i386 and linux-arm.
Test on linux-i386 is OK but on linux-arm, I got unexpected values
"30-12-99" as datetime and "2.12199579096527E-314" as float, which are different
from values previously set. (except INT and VARCHAR fields)

---linux-i386
INT, VARCHAR,   DATETIME,   DOUBLE
0, 9-3-21 08:50:23, 9-3-21 08:50:23, 0
1, 9-3-21 12:16:06, 9-3-21 12:16:06, 0.142857142857143
2, 9-3-21 15:41:49, 9-3-21 15:41:49, 0.285714285714286
3, 9-3-21 19:07:32, 9-3-21 19:07:32, 0.428571428571429
4, 9-3-21 22:33:15, 9-3-21 22:33:15, 0.571428571428571
5, 10-3-21 01:58:58, 10-3-21 01:58:58, 0.714285714285714
6, 10-3-21 05:24:40, 10-3-21 05:24:40, 0.857142857142857
7, 10-3-21 08:50:23, 10-3-21 08:50:23, 1
8, 10-3-21 12:16:06, 10-3-21 12:16:06, 1.14285714285714
9, 10-3-21 15:41:49, 10-3-21 15:41:49, 1.28571428571429

---linux-arm-
INT, VARCHAR,   DATETIME,   DOUBLE
0, 9-3-21 08:55:53, 30-12-99, 2.12199579096527E-314
1, 9-3-21 12:21:36, 30-12-99, 2.12199579096527E-314
2, 9-3-21 15:47:18, 30-12-99, 2.12199579096527E-314
3, 9-3-21 19:13:01, 30-12-99, 2.12199579096527E-314
4, 9-3-21 22:38:44, 30-12-99, 2.12199579096527E-314
5, 10-3-21 02:04:27, 30-12-99, 2.12199579096527E-314
6, 10-3-21 05:30:10, 30-12-99, 2.12199579096527E-314
7, 10-3-21 08:55:53, 30-12-99, 2.12199579096527E-314
8, 10-3-21 12:21:36, 30-12-99, 2.12199579096527E-314
9, 10-3-21 15:47:19, 30-12-99, 2.12199579096527E-314

I used a shared library libsqlite3.so included in the "DB Browser for SQLite",
so it should work. What can cause such a problem only in the specific field
on the specific platform?

Thank you in advance for any advice.

Toru




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


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


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


Re: [fpc-pascal] Unicode chars losing information

2021-03-09 Thread Tomas Hajny via fpc-pascal

On 2021-03-09 09:46, Graeme Geldenhuys via fpc-pascal wrote:

On 09/03/2021 1:44 am, Tomas Hajny via fpc-pascal wrote:
UnicodeString may be used in a program simply because the included 
unit

has it used in its interface. That may be the case even if there's no
use of characters outside of US ASCII at all.


So FPC rather goes with the fact that data may be *silently* lost 
during
encoding conversions? That doesn't seem like a safe default behaviour 
to

me.


The same happens e.g. if you configure your terminal to use a font that 
doesn't contain all the characters which may appear in the output - the 
compiler cannot know all the circumstances and thus cannot handle all of 
them; among others due to the fact that there are decisions to be made 
based on weighing pros and cons in the particular use case and those 
simply aren't 'one size fits all'.


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


Re: [fpc-pascal] Cannot write datetime field on sqlite3 database on ARM

2021-03-09 Thread LacaK via fpc-pascal
I did run test program on RaspberryPI: Linux+ARM and results are as 
expected.

(FPC 3.2.0)

-Laco.

Dňa 9.3.2021 o 1:47 Toru Takubo via fpc-pascal napísal(a):

On 2021/03/08 16:54, Michael Van Canneyt via fpc-pascal wrote:



On Mon, 8 Mar 2021, Toru Takubo via fpc-pascal wrote:


Hi,

I am developing my app on Windows and building apps for other
platforms by using cross compiler. Now I have a problem only
occurred on Linux ARM.

The problem is that it cannot write datetime field on sqlite3
database. It can read/write other fields like int, varchar
or blob, but always write zero in datetime (maybe float as well)
field.

Does anyone have an idea about this issue? I am not sure it is
fpc issue, but better to report bug?


It sounds like a floating point problem. As you probably know, a 
TDateTime

type is actually a double type. Did you try with a float value ?

The DB explorer tools probably just use strings to read/write from the
database, so they will not be bothere by such things, but FPC stores 
dataset

values in 'native' formats in memory.

I don't know what to advise to further investigate the issue, One 
thing to
try would be to test whether normal float arithmetic or date 
arithmetic works.

If not, then the compiler people will need to give more advice.



I created a simple test code, and ran on linux-i386 and linux-arm.
Test on linux-i386 is OK but on linux-arm, I got unexpected values
"30-12-99" as datetime and "2.12199579096527E-314" as float, which are 
different

from values previously set. (except INT and VARCHAR fields)

---linux-i386
INT, VARCHAR,   DATETIME,   DOUBLE
0, 9-3-21 08:50:23, 9-3-21 08:50:23, 0
1, 9-3-21 12:16:06, 9-3-21 12:16:06, 0.142857142857143
2, 9-3-21 15:41:49, 9-3-21 15:41:49, 0.285714285714286
3, 9-3-21 19:07:32, 9-3-21 19:07:32, 0.428571428571429
4, 9-3-21 22:33:15, 9-3-21 22:33:15, 0.571428571428571
5, 10-3-21 01:58:58, 10-3-21 01:58:58, 0.714285714285714
6, 10-3-21 05:24:40, 10-3-21 05:24:40, 0.857142857142857
7, 10-3-21 08:50:23, 10-3-21 08:50:23, 1
8, 10-3-21 12:16:06, 10-3-21 12:16:06, 1.14285714285714
9, 10-3-21 15:41:49, 10-3-21 15:41:49, 1.28571428571429

---linux-arm-
INT, VARCHAR,   DATETIME,   DOUBLE
0, 9-3-21 08:55:53, 30-12-99, 2.12199579096527E-314
1, 9-3-21 12:21:36, 30-12-99, 2.12199579096527E-314
2, 9-3-21 15:47:18, 30-12-99, 2.12199579096527E-314
3, 9-3-21 19:13:01, 30-12-99, 2.12199579096527E-314
4, 9-3-21 22:38:44, 30-12-99, 2.12199579096527E-314
5, 10-3-21 02:04:27, 30-12-99, 2.12199579096527E-314
6, 10-3-21 05:30:10, 30-12-99, 2.12199579096527E-314
7, 10-3-21 08:55:53, 30-12-99, 2.12199579096527E-314
8, 10-3-21 12:21:36, 30-12-99, 2.12199579096527E-314
9, 10-3-21 15:47:19, 30-12-99, 2.12199579096527E-314

I used a shared library libsqlite3.so included in the "DB Browser for 
SQLite",
so it should work. What can cause such a problem only in the specific 
field

on the specific platform?

Thank you in advance for any advice.

Toru




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


Re: [fpc-pascal] Unicode chars losing information

2021-03-09 Thread Michael Van Canneyt via fpc-pascal



On Tue, 9 Mar 2021, Mattias Gaertner via fpc-pascal wrote:


On Tue, 9 Mar 2021 08:04:54 +0100
Sven Barth via fpc-pascal  wrote:


[...]
FPC is not Java. In FPC you have more fine-grained control over the
resulting binary than "install big, fat runtime". Not to mention that
FPC can target resource constrained systems as well.


Optional is good.

Maybe the defaults can be changed. For example the macOS dmg and
Linux-x86-64 debs/rpms could install an fpc.cfg containing

#ifndef FPNonUnicode
-Facwstring
-Fcutf-8
#endif

For minimal programs pass -dFPNonUnicode


Our mails crossed.

That corresponds to what I proposed, with minor differences. 
The additional #ifndef FPNonUnicode is also a good idea.


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


Re: [fpc-pascal] Cannot write datetime field on sqlite3 database on ARM

2021-03-09 Thread Michael Van Canneyt via fpc-pascal



On Tue, 9 Mar 2021, Toru Takubo via fpc-pascal wrote:



thank you for the test program. I tested on linux 64-bit, that works OK 

too.


When you look in the database on the arm machine  with an sqlite tool, do
you see the correct values or are the inserted values wrong ?

(I'm trying to establish whether the problem happens during read  or write)

Looking into the database with "DB Browser for SQLite", those fields are all 
"0".
If you set some value in those fields by the tool, you can read them with fpc 
program.

Therefore problem happens on writing values, I believe.


It certainly seems so, yes.

I used a shared library libsqlite3.so included in the "DB Browser for 

SQLite",
so it should work. What can cause such a problem only in the specific 

field

on the specific platform?


Seems like either a floating point issue, or an alignment issue.
I know ARM has some specific behaviour with regard to alignment.

Unfortunately, I have no idea what to test or the means to test it.
Someone more familiar with ARM will need ro test.


It would be better for me to create a bug report?


At this point I think this would indeed be necessary.

So, yes, please add a bugreport !

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


Re: [fpc-pascal] Unicode chars losing information

2021-03-09 Thread Michael Van Canneyt via fpc-pascal



On Tue, 9 Mar 2021, Graeme Geldenhuys via fpc-pascal wrote:


On 09/03/2021 1:44 am, Tomas Hajny via fpc-pascal wrote:
UnicodeString may be used in a program simply because the included unit 
has it used in its interface. That may be the case even if there's no 
use of characters outside of US ASCII at all.


So FPC rather goes with the fact that data may be *silently* lost during
encoding conversions? That doesn't seem like a safe default behaviour to
me.


No, we give the programmer a choice: 
* Not use unicode conversion at all.

* Use the C library to handle conversion (cwstring).
* Use FPC native code to handle conversion (fpwidestring).
* Some other means.

Since the compiler cannot reliably detect that a choice was made, 
it also cannot make the choice for you, because the choice also cannot 
be undone by the compiler.


This mechanism implies the programmer *has* to make that choice.

This is not different from the threading driver mechanism, for which Lazarus 
adds
some {$IFDEF } mechanisms in the program uses clause.

But, I have been thinking about this. What we can do to alleviate this is the 
following:

Use the -FaNNN option of the command line.

This option will insert NNN implicitly in the uses clause of the program.

So, we can add 
-Fafpwidestring

or
-Facwstring

in the default generated fpc.cfg config file for selected platforms (mac, linux
i386,64-bit, *bsd). The result will be that a widestring driver unit will be 
inserted by default for those platforms.


By using the necessary IFDEF mechanism in the config file, we can avoid
inserting it for windows (which does not need it) or the smaller embedded 
platforms
(which cannot handle it).

People that don't need/want this can remove the config setting from the file. 
All the others leave it as-is and will get their desired conversion mechanisms

'for free'.

This way a default choice is made for you on those platforms, but you can still 
100% control
it.

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


Re: [fpc-pascal] Unicode chars losing information

2021-03-09 Thread Mattias Gaertner via fpc-pascal
On Tue, 9 Mar 2021 08:04:54 +0100
Sven Barth via fpc-pascal  wrote:

>[...]
> FPC is not Java. In FPC you have more fine-grained control over the
> resulting binary than "install big, fat runtime". Not to mention that
> FPC can target resource constrained systems as well.

Optional is good.

Maybe the defaults can be changed. For example the macOS dmg and
Linux-x86-64 debs/rpms could install an fpc.cfg containing

#ifndef FPNonUnicode
-Facwstring
-Fcutf-8
#endif

For minimal programs pass -dFPNonUnicode

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


Re: [fpc-pascal] Cannot write datetime field on sqlite3 database on ARM

2021-03-09 Thread Toru Takubo via fpc-pascal

On 2021/03/09 17:07, Michael Van Canneyt via fpc-pascal wrote:



On Tue, 9 Mar 2021, Toru Takubo via fpc-pascal wrote:


I don't know what to advise to further investigate the issue, One thing to
try would be to test whether normal float arithmetic or date arithmetic works.
If not, then the compiler people will need to give more advice.



I created a simple test code, and ran on linux-i386 and linux-arm.
Test on linux-i386 is OK but on linux-arm, I got unexpected values
"30-12-99" as datetime and "2.12199579096527E-314" as float, which are different
from values previously set. (except INT and VARCHAR fields)

---linux-i386
INT, VARCHAR,   DATETIME,   DOUBLE
0, 9-3-21 08:50:23, 9-3-21 08:50:23, 0
1, 9-3-21 12:16:06, 9-3-21 12:16:06, 0.142857142857143
2, 9-3-21 15:41:49, 9-3-21 15:41:49, 0.285714285714286
3, 9-3-21 19:07:32, 9-3-21 19:07:32, 0.428571428571429
4, 9-3-21 22:33:15, 9-3-21 22:33:15, 0.571428571428571
5, 10-3-21 01:58:58, 10-3-21 01:58:58, 0.714285714285714
6, 10-3-21 05:24:40, 10-3-21 05:24:40, 0.857142857142857
7, 10-3-21 08:50:23, 10-3-21 08:50:23, 1
8, 10-3-21 12:16:06, 10-3-21 12:16:06, 1.14285714285714
9, 10-3-21 15:41:49, 10-3-21 15:41:49, 1.28571428571429

---linux-arm-
INT, VARCHAR,   DATETIME,   DOUBLE
0, 9-3-21 08:55:53, 30-12-99, 2.12199579096527E-314
1, 9-3-21 12:21:36, 30-12-99, 2.12199579096527E-314
2, 9-3-21 15:47:18, 30-12-99, 2.12199579096527E-314
3, 9-3-21 19:13:01, 30-12-99, 2.12199579096527E-314
4, 9-3-21 22:38:44, 30-12-99, 2.12199579096527E-314
5, 10-3-21 02:04:27, 30-12-99, 2.12199579096527E-314
6, 10-3-21 05:30:10, 30-12-99, 2.12199579096527E-314
7, 10-3-21 08:55:53, 30-12-99, 2.12199579096527E-314
8, 10-3-21 12:21:36, 30-12-99, 2.12199579096527E-314
9, 10-3-21 15:47:19, 30-12-99, 2.12199579096527E-314


thank you for the test program. I tested on linux 64-bit, that works OK too.

When you look in the database on the arm machine  with an sqlite tool, do
you see the correct values or are the inserted values wrong ?

(I'm trying to establish whether the problem happens during read  or write)


Looking into the database with "DB Browser for SQLite", those fields are all 
"0".
If you set some value in those fields by the tool, you can read them with fpc 
program.
Therefore problem happens on writing values, I believe.



I used a shared library libsqlite3.so included in the "DB Browser for SQLite",
so it should work. What can cause such a problem only in the specific field
on the specific platform?


Seems like either a floating point issue, or an alignment issue.
I know ARM has some specific behaviour with regard to alignment.

Unfortunately, I have no idea what to test or the means to test it.
Someone more familiar with ARM will need ro test.


It would be better for me to create a bug report?

Toru

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


Re: [fpc-pascal] Cannot write datetime field on sqlite3 database on ARM

2021-03-09 Thread Gabriele Cappelletto via fpc-pascal
It happened to me with Firebird too. Only that the error gave it to me 
in reading, that is db.fieldByName ('cc'). AsDateTime


Il 08/03/21 02:31, Toru Takubo via fpc-pascal ha scritto:

Hi,

I am developing my app on Windows and building apps for other
platforms by using cross compiler. Now I have a problem only
occurred on Linux ARM.

The problem is that it cannot write datetime field on sqlite3
database. It can read/write other fields like int, varchar
or blob, but always write zero in datetime (maybe float as well)
field.

Does anyone have an idea about this issue? I am not sure it is
fpc issue, but better to report bug?

My observations are as follows:

1. I work with Lazarus 2.0.12/FPC 3.2.0 release version.
2. Target machine is Raspberry Pi OS on Raspberry Pi 3 Model B V1.2.
3. My app consists of sqlite3conn and sqldb unit.
4. The problem occurred on Linux ARM. It does NOT on Windows i386/x86_64,
 Linux i386/x86_64 and Linux AArch64.
5. I installed "DB Browser for SQLite" on Raspi as a reference. It can
 write datetime field normally. My app can read it.

Toru

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

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


Re: [fpc-pascal] Unicode chars losing information

2021-03-09 Thread Graeme Geldenhuys via fpc-pascal
On 09/03/2021 1:44 am, Tomas Hajny via fpc-pascal wrote:
> UnicodeString may be used in a program simply because the included unit 
> has it used in its interface. That may be the case even if there's no 
> use of characters outside of US ASCII at all.

So FPC rather goes with the fact that data may be *silently* lost during
encoding conversions? That doesn't seem like a safe default behaviour to
me.

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


Re: [fpc-pascal] Cannot write datetime field on sqlite3 database on ARM

2021-03-09 Thread Michael Van Canneyt via fpc-pascal



On Tue, 9 Mar 2021, Toru Takubo via fpc-pascal wrote:


I don't know what to advise to further investigate the issue, One thing to
try would be to test whether normal float arithmetic or date arithmetic 
works.

If not, then the compiler people will need to give more advice.



I created a simple test code, and ran on linux-i386 and linux-arm.
Test on linux-i386 is OK but on linux-arm, I got unexpected values
"30-12-99" as datetime and "2.12199579096527E-314" as float, which are 
different

from values previously set. (except INT and VARCHAR fields)

---linux-i386
INT, VARCHAR,   DATETIME,   DOUBLE
0, 9-3-21 08:50:23, 9-3-21 08:50:23, 0
1, 9-3-21 12:16:06, 9-3-21 12:16:06, 0.142857142857143
2, 9-3-21 15:41:49, 9-3-21 15:41:49, 0.285714285714286
3, 9-3-21 19:07:32, 9-3-21 19:07:32, 0.428571428571429
4, 9-3-21 22:33:15, 9-3-21 22:33:15, 0.571428571428571
5, 10-3-21 01:58:58, 10-3-21 01:58:58, 0.714285714285714
6, 10-3-21 05:24:40, 10-3-21 05:24:40, 0.857142857142857
7, 10-3-21 08:50:23, 10-3-21 08:50:23, 1
8, 10-3-21 12:16:06, 10-3-21 12:16:06, 1.14285714285714
9, 10-3-21 15:41:49, 10-3-21 15:41:49, 1.28571428571429

---linux-arm-
INT, VARCHAR,   DATETIME,   DOUBLE
0, 9-3-21 08:55:53, 30-12-99, 2.12199579096527E-314
1, 9-3-21 12:21:36, 30-12-99, 2.12199579096527E-314
2, 9-3-21 15:47:18, 30-12-99, 2.12199579096527E-314
3, 9-3-21 19:13:01, 30-12-99, 2.12199579096527E-314
4, 9-3-21 22:38:44, 30-12-99, 2.12199579096527E-314
5, 10-3-21 02:04:27, 30-12-99, 2.12199579096527E-314
6, 10-3-21 05:30:10, 30-12-99, 2.12199579096527E-314
7, 10-3-21 08:55:53, 30-12-99, 2.12199579096527E-314
8, 10-3-21 12:21:36, 30-12-99, 2.12199579096527E-314
9, 10-3-21 15:47:19, 30-12-99, 2.12199579096527E-314


thank you for the test program. I tested on linux 64-bit, that works OK too.

When you look in the database on the arm machine  with an sqlite tool, do
you see the correct values or are the inserted values wrong ?

(I'm trying to establish whether the problem happens during read  or write)



I used a shared library libsqlite3.so included in the "DB Browser for 
SQLite",

so it should work. What can cause such a problem only in the specific field
on the specific platform?


Seems like either a floating point issue, or an alignment issue.
I know ARM has some specific behaviour with regard to alignment.

Unfortunately, I have no idea what to test or the means to test it.
Someone more familiar with ARM will need ro test.

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