Recent

Author Topic: Getting and checking language mode  (Read 131 times)

MarkMLl

  • Jr. Member
  • **
  • Posts: 75
Getting and checking language mode
« on: August 25, 2019, 02:54:58 pm »
I'm revisiting some stuff I wrote a few years ago which puts a form and associated code in a dynamically-linkable library (.so) which can be reloaded on receipt of a HUP signal or if the library has been recompiled (date in the filename). My experience is that my implementation is pretty robust, and I'm reusing it to support a handheld 'scope (https://jyetech.com/dso-coral-112a-oscilloscope/) and possibly for some older stuff with the intention of publishing it somewhere.

I'm confident in my handling of "magic numbers" describing the API presented by both the library and main program, and have a workable way that the library can be compiled statically for debugging without significant code changes. However noting the Dire Warning "it may be that the arguments or return values differ if the library is compiled in 2 different modes" https://www.freepascal.org/docs-html/prog/progse55.html I have to ask:

Is there an easy way to generate a numeric value encoding the compilation mode used for a particular unit, together with any relevant overrides (cdecl etc.)?

MarkMLl

Bart

  • Hero Member
  • *****
  • Posts: 3480
    • Bart en Mariska's Webstek
Re: Getting and checking language mode
« Reply #1 on: August 25, 2019, 03:37:44 pm »
If I understand correctly that is about the size of the arguments, which you can check with SizeOf.

Bart

MarkMLl

  • Jr. Member
  • **
  • Posts: 75
Re: Getting and checking language mode
« Reply #2 on: August 25, 2019, 03:53:24 pm »
True, so in principle and with reference to https://www.freepascal.org/docs-html/current/ref/refsu4.html#x26-250003.1.1 if you avoid woolly terms like "integer" you should be OK. But then there's still the difference between cdecl and pascal, variations in packing behaviour, and so on :-/

OTOH, if the function which returned the magic number used cdecl but was called using the pascal convention things would fall over long before any more detailed checks started to be made. And if packing was wrong the functions which e.g. copied menu items from the library form to the main program would be visibly broken.

But I'm still left feeling a bit uncomfortable since there's a whole lot of stuff which apparently can't be checked using e.g. $ifopt

MarkMLl