Forum > General

Question on portable code

(1/3) > >>

MathMan:
Hi all,

I am currently working with FPC 2.6.4.

For the math library I develope I do have a question on portable code. Naturally the lib contains a lot of statements like


--- Code: ---  X := X + a;

--- End code ---

Using Inc instead will produce significantly faster executables on my Version of FPC. As I want to produce a lib that can be compiled with as many Pascal compilers as possible - the "portable" aspect - I do have the following questions

* is Inc/Dec a common Pascal language extension (or should I stay with the above for portablilty)?
* if Inc/Dec is not portable can I expect better optimization in the upcomming FPC 3.x.x Versions (so that i can stay with the above)?

If the answers two both questions are "no" then I do see two Options to make the high-speed version avail to FPC users

* I could define a compile time switch and integrate both variants in one source. However this will render the sources unreadable, as they will then mainly consist of "{ifdef ...} ... {endif}" instead of anything useful.
* I could translate the portable version into an optimized FPC version and include both in the package. However this will require me to maintain coherence between the two files (which are already >20.000 lines and double to end of this year).

Comments, suggestions anyone?

Kind regards,
MathMan

Blaazen:
It should be safe. There are no limitations mentioned in docs: http://www.freepascal.org/docs-html/rtl/system/inc.html

taazz:
third solution create your own inc function with the ifdef code and use that instead (make it inlined too).

MathMan:

--- Quote from: Blaazen on August 11, 2015, 08:43:28 am ---It should be safe. There are no limitations mentioned in docs: http://www.freepascal.org/docs-html/rtl/system/inc.html

--- End quote ---

With "safe" you mean it's a common Pascal RTL function?

MathMan:

--- Quote from: taazz on August 11, 2015, 08:49:59 am ---third solution create your own inc function with the ifdef code and use that instead (make it inlined too).

--- End quote ---

Good one - didn't catch that. Will consider if there is no other solution avail.

Navigation

[0] Message Index

[#] Next page

Go to full version