Content deleted Content added
No edit summary |
|||
Line 361:
=== Import ===
Unlike C and C++, Objective-C includes an <code>#import</code> directive that is like <code>#include</code> but results in a file being included only once {{endash}} eliminating the need for include guards and [[pragma once|<code>#pragma once</code>]].
<syntaxhighlight lang="objective-c">
#import <Foundation/Foundation.h>
#import "MyClass.h"
</syntaxhighlight>
In [[Microsoft Visual C++]] (MSVC), there also exists an <code>#import</code> preprocessor directive, used to import type libraries.<ref>{{Cite web|url=https://learn.microsoft.com/en-us/cpp/preprocessor/hash-import-directive-cpp|title = #import directive (C++)}}</ref> It is a nonstandard directive.
<syntaxhighlight lang="cpp">
#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF", "ADOEOF")
</syntaxhighlight>
The Objective-C directive should not be confused with the C++ keyword <code>import</code>, which is used to import C++ [[Precompiled header#Modules|modules]] (since [[C++20]]), and is not a preprocessor directive.
|