MQL5Book/Scripts/p2/ExternHeader2.mqh
2025-06-12 13:40:26 +01:00

32 lines
1.1 KiB
MQL5

//+------------------------------------------------------------------+
//| ExternHeader2.mqh |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#ifdef USE_INCLUDE_WORKAROUND
// a replacement for extern variable could be:
#include "ExternCommon.mqh" // which contains:
//+------------------------------------------+
//| /* ExternCommon.mqh */ |
//| int x; |
//+------------------------------------------+
#else
extern int x;
#endif
// ERROR:
// extern short y; // variable 'y' already defined with different type
//+------------------------------------------------------------------+
//| Mockup decrement function using 'x' |
//+------------------------------------------------------------------+
void dec()
{
x--;
}
//+------------------------------------------------------------------+