0

In python if we run

import sys
print(sys.path)

it will give us a list of directories where python interpreter or compiler searches in when an import keyword encountered.

similarly is there a command(or a CLI command) or function in c++ which do the same as python's sys.path

More information, I am using windows, mingw gcc version 6.3.0

Samer
  • 123
  • 1
  • 8
  • C++ doesn't have anything like `import`, so what would an equivalent function be? – Barmar May 02 '19 at 00:26
  • @Chipster He's not asking about listing a directory, he's asking about a search path used for importing modules. – Barmar May 02 '19 at 00:27
  • @Barmar `import` is roughly equivalent to `include` but slightly more flexible. –  May 02 '19 at 00:27
  • but c++ have #include equivalent as import – Samer May 02 '19 at 00:27
  • `#include` happens at compile time, not while the program is running. – Barmar May 02 '19 at 00:27
  • @Barmar as in the working directory? –  May 02 '19 at 00:28
  • Possible duplicate of [What are the GCC default include directories?](https://stackoverflow.com/questions/4980819/what-are-the-gcc-default-include-directories) – Ryan Haining May 02 '19 at 00:28
  • 1
    The closest I can think of are the set of directories you can update with `-I` and `-L` when compiling and linking. – Barmar May 02 '19 at 00:29
  • 3
    What are you intending to do with this information in C++? By the time the program is running, it's too late to do anything with the directories used for `#include` and linking. – Barmar May 02 '19 at 00:32
  • @barmar I just want to understand how it works. In future if I create my own files what are options I have to place my files . – Samer May 02 '19 at 00:35
  • 2
    Understand how what works? Python is interpreted, C++ is compiled. Python loads modules while the script is running, with C++ you link everything when you're compiling. – Barmar May 02 '19 at 00:36
  • As far as I know, C++ doesn't provide any introspection for this information. – Barmar May 02 '19 at 00:37
  • @RyanHaining Thanks for suggestion, it solved my question I guess, I can see some folder in the command line. I guess those are the folders compiler searching – Samer May 02 '19 at 00:38
  • @Barmar Thanks for your answer. I meant how C++ works. – Samer May 02 '19 at 00:39
  • Since it is duplicated Do I have to delete the question now – Samer May 02 '19 at 00:40
  • @Chipster your suggestions also helped me. thanks. – Samer May 02 '19 at 00:40
  • you don't have to delete the question, it will be marked as a duplicate following other close voters. – Ryan Haining May 02 '19 at 02:16

0 Answers0