How to define path for an include file located in different folder ? - page 2

 
lippmaje:

Include directives and preprocessor macros are processed line by line in linear order. Same as with the C preprocessor. Otherwise things like this wouldn't work:

...

The path specifier will be passed to the operating system's runtime environment as is. It's up to the OS how to deal with forward or backward slashes.

Windows (since XP afaik) is able to translate forward slashes into native format, which makes path specs with forward slashes more portable.

I need to return to this, because the statement is wrong.

Macro preprocessing is done after inclusion has been performed, while evaluation has been done line by line.

I would say, my statement was a little vauge in its expression of clarity, but see following example:

Example 1:

#define testing_include
#define include_file "123store.mqh"
#define INCLUDE_MACRO(x) #x
#ifdef testing_include
#include INCLUDE_MACRO(123store.mqh)
#else 
#include include_file
#endif

Example 2:

//#define testing_include
#define include_file "123store.mqh"
#define INCLUDE_MACRO(x) #x
#ifdef testing_include
#include INCLUDE_MACRO(123store.mqh)
#else 
#include include_file
#endif


Neither work because preprocessing of macros is actually done after all preprocessor directives have been parced.

So, yes, it is true, preprocessor directives get read line by line, but the actual processing of them is done after this step.


Here is an article on forward slashes:

https://www.howtogeek.com/181774/why-windows-uses-backslashes-and-everything-else-uses-forward-slashes/

 
Dominik Egert:

I need to return to this, because the statement is wrong.

Macro preprocessing is done after inclusion has been performed, while evaluation has been done line by line.

I would say, my statement was a little vauge in its expression of clarity, but see following example:

Example 1:

Example 2:


Neither work because preprocessing of macros is actually done after all preprocessor directives have been parced.

So, yes, it is true, preprocessor directives get read line by line, but the actual processing of them is done after this step.


Here is an article on forward slashes:

https://www.howtogeek.com/181774/why-windows-uses-backslashes-and-everything-else-uses-forward-slashes/

Neither work because Metaquotes preprocessor doesn't implement the whole C standard preprocessor, macro expansion are not working with #include. It's an MQL limitation.

https://gcc.gnu.org/onlinedocs/cpp/Computed-Includes.html#Computed-Includes

Computed Includes (The C Preprocessor)
  • gcc.gnu.org
Computed Includes (The C Preprocessor)
 

@Dominik I never got that far in using macros, so I can't comment from the top of my head, but Alain gave you the right answer anyways.

Keep it up guys, again a great read. Going to check out the links for sure.

 
I've been experimenting with macros quite a lot and I found the limitations mentioned by Alain as well. Long before this post to be honest.

Since I am coming from vanilla C/C++ I am aware of the processing of macros. It is in fact so that I am by now so caught up in mql, I sometimes forget the in/difference by the two languages...

I was some time ago at the brink of moving back to c/c++, because of the limitations given by mql. But then I noticed the implied limitations given by using dlls as the main working environment. So I kept by mql.

Most of the tasks can be done in mql, leaving out lots of advantages a real c/c++ compiler brings along.