The #import Directive


#import "filename" [attributes]

#import <filename> [attributes]

The filename is enclosed in either double-quotes or angle-brackets (i.e., a less-than sign before and a greater-than sign after). The choice has a significance described below.

Within its enclosure, the filename has a complex syntax, not least because it need not actually name a file, not directly. In the forms

file: file

libid: libid

progid: progid

the prefix is case insensitive and may be followed by any amount of white space, including none, before the file, libid or progid.


In the following list of syntactically valid attributes for the #import directive in Microsoft Visual C++ version 13.00.9466, those that the product documentation omits from the list of #import Attributes on the page titled The #import Directive are highlighted yellow.

Some of the product documentation’s omissions are clearly accidents: for instance, lcid and version are shown in two examples on that same page, despite being then omitted from the list. Some are just as plainly deliberate: for instance, it is nothing but consistent that function_mapping should be undocumented, given its relationship to other undocumented constructions such as #pragma start_map_region.

Anything else causes a warning (C4185) about being an unknown #import attribute. Failure to supply the expected number of arguments for an attribute, including to supply arguments when none are expected, causes a warning (C4186).

Some attributes form incompatible pairs:

To give both of a pair causes a warning (C4187).