@MarkMLl — I understand this. I don't want to force anyone to change the behavior of macros, but just solve my problem and adapt the IDE to my own requirements. You may find it ridiculous, but just what I want to achieve is going to work for me, for this particular project.
Ok guys, finally I did what I wanted to get. To have this syntax:
whenever {conditions to met} fail assertion;
I can define macros for the words
whenever and
fail (just like I did before), while the word
assertion can be a normal inline routine calling
System.Error(reAssertionFailed). It is so simple. And now when the runtime error is thrown, the call to
System.Error(reAssertionFailed) is inlined, so the IDE will always highlight the line containing the call to the procedure
assertion, so the line I needed to be highlighted. I'm an idiot and unfortunately I have wasted your time.
Solution looks like this:
// in the include file with my macros:
{$IFDEF GAME_BUILD_DEBUG}
{$DEFINE whenever := if}
{$DEFINE fail := then}
{$ELSE}
{$DEFINE whenever := //}
{$ENDIF}
// in the separate file:
{$PUSH}
{$INLINE ON}
procedure Assertion(); inline;
begin
System.Error(reAssertionFailed);
end;
{$POP}
// in any of the project source file:
procedure Foo(ADataSize: Integer);
begin
whenever ADataSize <= 0 fail assertion; // Macros with custom assertion routine, only for "debug" builds.
// other stuff
end;
I am just wondering about one more thing. How it works that the contents of the
System unit are always available, even if this unit is not added to the
uses list. Is there a way to do something like this with custom unit, so it will be always visible to the compiler without adding it to the
uses list?