[Gambas-user] Working with .so library
admin at allunix.ru
Tue Jun 25 05:56:39 CEST 2019
Ok, answering my own question, it's easier then I thought. Gambas
actually allows the same enum declaration as C does, I mean I can use
multiple strings despite it's never mentioned in documentation. So it's
basically .h file copy-paste process, nothing more.
25.06.2019 10:27, Admin пишет:
> Ok, another question:
> I am very far from understanding C/C++, so I only rely on base logic.
> The documentation to a .so library I'm working with is stating that I
> have to call a function with patameter A and it's value B. Like this:
> libfptr_set_param_int(fptr, LIBFPTR_PARAM_TAX_TYPE, LIBFPTR_TAX_VAT18);
> As I understand from drivers reaction, it expects rather integers then
> So then I suppose those are ENUM values given in a header file, and
> the only way I can call a function is actually count the number of a
> string in enum declaration (starting with 0) and providing it's number
> as an integer value to a finction.
> Right? I mean I can also create an ENUM array in my Gambas project and
> this would work the same way, but since there are hundreds of strings,
> that'd be tuff. And there's no other way.
> 24.06.2019 22:26, Cedron Dawg пишет:
>> The question was why would a language require that kind of
>> complexity. I don't think it all that complex once you understand
>> it. However, the apparent complexity in this case is dealing with a
>> pointer to a pointer. Well, had C been implemented with a pass by
>> reference convention this complexity in this case wouldn't exist.
>> Pass by reference means you ultimately are pushing the address of a
>> variable on the stack before the call, and pass by value means you
>> push the value. Since in assembly the pushes are explicit, there is
>> no default convention. For higher level languages (even C) when the
>> function call syntax is translated into machine code, the decision
>> has to be made which method to use. The C designers chose pass by
>> value as a default. In contrast, FORTRAN, COBOL, and the other
>> prevailing languages at the time (including PASCAL which C is most
>> modeled after) did pass by reference.
>> I do agree that pass by value does more closely resemble what the CPU
>> does. Especially when you consider that you are most often pushing
>> register values which may or may not be an address. It is also
>> possible to push the address of a memory location without first
>> storing it in a register.
>> C could have been written with a pass by reference convention and
>> that would not have had any impact on how the CPU works, but because
>> it is pass by value in order to implement pass by reference you
>> literally have to pass the reference as a value, e.g. the & operator
>> which returns the address.
>> But you know all this, so I don't see what we are arguing about. All
>> I am saying is this particular complexity is due to C's pass by value
>> convention, and wouldn't exist if C were pass by reference.
>> ----- Original Message -----
>> From: "Benoît Minisini" <g4mba5 at gmail.com>
>> "Passing by reference" means nothing at the CPU level.
>> You can only send a pointer that points at a memory address.
>> Which C, as a low-level language, hopefully does not try to hide with
>> syntactic sugar.
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
More information about the User