What is the difference between #import and #include in C ++?

Possible duplicate:
C ++ enables and modifies imports

Can someone explain the difference and where can I use one or the other?

+3
source share
4 answers
  • #importimports information (types, functions, variables, etc.) from a .lib file. This is a non-standard directive.
  • #include includes a header file.

See these topics:

+5
source
  • #include contains the file in the current compilation unit.
  • #import does not exist in the C ++ standard.
+5
source

#include " " .

#importis not in the standard C++, but is an extension provided by some compiler. There is no consensus on what he is doing. For GCC, it is equivalent #include, but try to ensure that the file is not yet included. For MSVC, this may have a different meaning.

Better to avoid #import(unfortunately) if you want to write portable code for multiple compilers.

+3
source

All Articles