<p>Is there a way to prevent packages in Delphi to implicitly import units that are not listed in the "Contains" list? I'm looking for a compiler directive that makes the build to fail if it tries to do an implicit import.</p>

<p>Problems occur when you install a package into the IDE that implicitly imports unit A and then you try to install another package that really contains unit A and the IDE tells you that it cannot install that package because unit A is already contained in the first package even if it shouldn't be!</p>

[{'answer_id': 81876, 'author': 'Jim McKeeth', 'author_id': 255, 'author_profile': 'https://Stackoverflow.com/users/255', 'pm_score': 3, 'selected': False, 'text': '<p>Delphi 2009 has the option to make warnings into failures.  That would do what you want to do as far as making it fail.</p>\n\n<p>To prevent the implicit importing you need to import it explicitly, or remove the unit that is implicitly importing it.</p>\n'}, {'answer_id': 81921, 'author': 'Lars Truijens', 'author_id': 1242, 'author_profile': 'https://Stackoverflow.com/users/1242', 'pm_score': 0, 'selected': False, 'text': '<p>There is no way to make that warning into an error. In Delphi 2009 you can make treat all warnings as errors.</p>\n\n<p>PS: It is an error in Delphi for .Net</p>\n'}, {'answer_id': 182022, 'author': 'Liron Yahdav', 'author_id': 62, 'author_profile': 'https://Stackoverflow.com/users/62', 'pm_score': 3, 'selected': True, 'text': '<p>If you\'re on a version of Delphi that\'s older that 2009, you can make the warning cause an error by using <a href="http://andy.jgknet.de/blog/?page_id=10" rel="nofollow noreferrer">DDevExtensions</a> (it\'s free). Once you install it, go to Tools > DDevExtensions - Options and in the "Compiler Enhancements" section select the "Active" check box and "Treat warnings as errors". You can add the warnings you want to not be treated as errors in the memo below that. Unfortunately, in your case, it looks like you just want one warning to be treated as an error, so you\'ll have to add pretty much every warning except the one about implicit importing to the list, although it\'s generally good coding practice to resolve all compiler warnings anyways, so you might want to just have all warnings cause errors.</p>\n'}]
['https://Stackoverflow.com/questions/81557', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4101/']