Does a function like this exist:
function FpcTargetDir: string;
begin
result:= {$I %FPCTARGETCPU%}+'-'+{$I %FPCTARGETOS%};
end;Above works for my needs, just wonder if something already exists in RTL or if it should be added for convenience.

Mailing lists / fpc-devel / 2008-01
5 messages · 3 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Does a function like this exist:
function FpcTargetDir: string;
begin
result:= {$I %FPCTARGETCPU%}+'-'+{$I %FPCTARGETOS%};
end;Above works for my needs, just wonder if something already exists in RTL or if it should be added for convenience.
It doesn't exists and i don't see a reason why it should be added. The above line is simple. And there is no generic rule that says that you need to encode TargetDir like cpu-os for every program.
Peter
Does a function like this exist: function FpcTargetDir: string; begin result:= {$I…
> result:= {$I %FPCTARGETCPU%}+'-'+{$I %FPCTARGETOS%}; Above works for my needs, just wonder if something already exists in RTL or if it should be added for convenience.
It doesn't exists and i don't see a reason why it should be added. The above line is simple.
The above line:
{$I %FPCTARGETCPU%}+'-'+{$I %FPCTARGETOS%};is the most ugliest crap I've seen in Pascal code, which is why I made the FpcTargetDir function.
FpcTargetDir is simply cleaner and more elegant.
And there is no generic rule that says that you need to encode TargetDir like cpu-os for every program.
Not for every program.. but never make assumptions about what people use fpc for ;-)
Fpc is a cross platform compiler and me I am working on stuff to clean the i386-win i386-linux style directories. I am also working on something to ship a binary Exe demos for windows, bsd, linux, all in one zip package. And my Exe and Elf need to be put in folders. FpcTargetDir folder is perfect to notify people what platform the Exe is for.
It should also come in handy for FPMAKE or you must have a function in use like that already.
So someone else has already found a need for it (me) along with fpmake authors (must have used a similar function?).
I will keep it in my own units.. but sometimes I wonder why I have all these useful functions that could be shipped with fpc so the public could use it, since you never know what the public is using fpc for. Who would have thought, for example, someone used FPC as a make build system. Never assume.
I vote for a patch that include the FpcTargetDir function in the RTL !
-Michael
The RTL should be kept lean and mean and not overloaded with nice-to-have for a couple of users. And in my opinion that you create create your personal
function FpcTargetDir:string
begin
result:={$I %FPCTARGETCPU%}+'-'+{$I %FPCTARGETOS%};
end;is a clean solution. An other user might code it like:
function FpcTargetDir:string
begin
result:=GetEnvironmentVariable('FPCTARGETDIR');
if result='' then
result:={$I %FPCTARGETCPU%}+'-'+{$I %FPCTARGETOS%};
end;It all depends on the personal preference of the user. And the end-result is just a syntax issue and asking for an extension. There have been numerous of discussions about this that just a shorter syntax is not a reason to extend FPC.
Maybe you should look into the sources more closely before talking programs you didn't create. The fpmake system can't use {$I %FPCTARGETCPU%}. It needs to retrieve the information from the compiler to support cross compiling.
Peter