1

In Visual Studio (Visual C++)Project setting we able see these settings:

  • Additional Include Directories (/I[path] compiler switch)
  • Additional #using Directories (/AI[path] compiler switch)

I want to know when to use these settings appropriately and what the main differences between these settings and how they affect on visual c++ linker and build time?

Please look at here -Visual Studio Property page

Community
  • 1
  • 1
Buddhika
  • 117
  • 7

1 Answers1

0

#using is for C++/CLI, not for standard C++.

A directory to search to resolve file references passed to the #using Directive directive.

assembly_A.cpp

// compile with: /clr /LD  
public ref class A {};  

assembly_B.cpp

// compile with: /clr /LD  
#using "assembly_A.dll"  
public ref class B {  
public:  
   void Test(A a) {}  
   void Test() {}  
};  

The option /AI[path] would set a search path where assembly_A.dll is placed.

More official info: VCCLCompilerTool.AdditionalUsingDirectories Property

273K
  • 29,503
  • 10
  • 41
  • 64
  • Thank you, that means #using mostly useful for C++/CLI rather than native C++ project settings? Also sorry I cannot vote up your answer since I have no privileges yet. – Buddhika May 03 '18 at 07:27
  • Yes, you are absolutely correct, it is useless in the native C++ project settings. – 273K May 03 '18 at 07:31
  • That is not accurate, the #import directive relies on it as well. And to locate WinRT meta files. All pure native C++ projects. – Hans Passant May 03 '18 at 09:00
  • @HansPassant https://learn.microsoft.com/en-us/cpp/preprocessor/hash-import-directive-cpp does not specify `/AI`, only `/I` in *Search Order for filename* – 273K May 03 '18 at 09:09