1
votes

I need to call Log.d that is defined inside FMX.Types. However my project is not a Firemonkey project, it's a VCL project. It compiles and works as expected but I receive this warning :

[dcc64 Hint] H2161 Warning: Duplicate resource: Type 12 (CURSOR GROUP), ID 32761; File c:\program files (x86)\embarcadero\studio\18.0\lib\Win64\release\FMX.Controls.Win.res resource kept; file c:\program files (x86)\embarcadero\studio\18.0\lib\Win64\release\Controls.res resource discarded.

Is their any global define that could indicate that the project is a VCL project so that I can omit to use FMX.Types and Log.d on VCL project ?

1
What is the question. Do you want to detect that the project is FMX? Or do you want to include FMX units in a VCL project? You appear to ask both. Please ask one question only. - David Heffernan
any of theses ! because they are both a solution to my problem. so detect that the project is FMX (to exclude fmx unit from the project) -- or -- any way to include a fmx units in a vcl project - Vyacheslav
Please pick one. You can't ask two questions in one. To help you pick one though, I can tell you that there is no conditional that identifies a project as being FMX. - David Heffernan
May I recommend side-stepping the entire issue by simply calling OutputDebugString instead of worrying about calling Log.d, thereby negating the need to pull in that FMX unit? Log.d calls OutputDebugString on Windows - you could easily make a wrapper routine that took similar parameters to Log.d. The conundrum then vanishes. - blong
@blong: perfect solution thanks !! Just sad you wrote it as a comment because it's deserve to be an acceptable solution ... - Vyacheslav

1 Answers

2
votes

To expand a little on my comment, you could sidestep the whole problem by simply "brewing your own" Log.d equivalent. Log.d calls OutputDebugString on Windows, so you could build something along the following lines and leave the FMX.Types helper unit entirely out of the equation, and avoiding the problem entirely:

uses Windows;

procedure Log(const Msg: string; const Args: array of const); overload;
var
  LMsg: string;
begin
  LMsg := Format(Msg, Args);
  OutputDebugString(PChar(LMsg));
end;

procedure Log(const Msg: string); overload;
begin
  OutputDebugString(PChar(Msg));
end;