#1 2024-09-05 21:16:44

phss_phss
Member
Registered: 2024-08-05
Posts: 6

Function not receiving value from json when compiled to Linux64

I have a function whose parameter is filled with a json from a request:

function TEventoService.AddColeta(const pAmostraDados: TDTOEventoColeta): TServiceCustomAnswer;

dto:

TDTOEventoColeta:
TDTOEventoColeta = packed record
NumeroAmostra: RawUtf8;
PostoId: Int64;
end;

The json sent:

[{
    "NumeroAmostra": "0101",
    "PostoId": 1
}]

When I compile this project for Windows64 in Lazarus, and run the application, it works correctly. But if I compile it for Linux64 in Lazarus, the json is not passed to the function.
When I insert an additional property in my dto:

TDTOEventoColeta = packed record
NumeroAmostra: RawUtf8;
PostoId: Int64;
Dummy: RawUtf8;
end;

And I compiled it for Linux64, it passed the json correctly to the function.
Can someone explain to me what happens?

Offline

#2 2024-09-06 05:47:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Function not receiving value from json when compiled to Linux64

My guess is that
- you are not using the same version of the FPC compiller and cross-compiller.
- you don't define the record using Rtti.RegisterFromText().

Extended RTTI for records are only available in FPC trunk, not in FPC 3.2.x.

Offline

#3 2024-09-06 17:58:11

mrbar2000
Member
From: Brazil
Registered: 2016-10-26
Posts: 89

Re: Function not receiving value from json when compiled to Linux64

We are using FPCDeluxe to crosscompile.
What version of lazarus and of fpc we should be choose?
To compile linux and windows from windows machine!

Offline

#4 2024-09-06 18:11:25

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Function not receiving value from json when compiled to Linux64

FPC fixes-3.2 is just fine.
Ensure you use the same version everywhere.

And note that you can have several FPC+Lazarus versions available on the same system.
Just use diverse folders and launch their own shortcut.

Offline

Board footer

Powered by FluxBB