Can I generate a custom compiler error? If so, how?

后端 未结 2 1315
孤街浪徒
孤街浪徒 2021-02-02 09:52

Here is what I want to do. I have a project that must be compiled in some version of Delphi or later. I would like to use a conditional compiler directive to test the Delphi ver

2条回答
  •  既然无缘
    2021-02-02 10:05

    You can use:

    {$Message HINT|WARN|ERROR|FATAL 'text string' } 
    
    
    
    
    {$MESSAGE 'Boo!'}                   emits a hint 
    {$Message Hint 'Feed the cats'}     emits a hint 
    {$messaGe Warn 'Looks like rain.'}  emits a warning 
    {$Message Error 'Not implemented'}  emits an error, continues compiling 
    {$Message Fatal 'Bang.  Yer dead.'} emits an error, terminates compiler 
    

    See: http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/compdirsmessagedirective_xml.html

    This works in Delphi 6 and later.

提交回复
热议问题