#include <iostream> extern int i; // Only declaration int func() { if (i) return i; else return -1; } int main() { int ret = func(); std::cout<<"Ret : "<<ret<<std::endl; }
Standard input is empty
/home/R77EVE/ccd6n643.o: In function `func()': prog.cpp:(.text+0x2): undefined reference to `i' /home/R77EVE/ccd6n643.o: In function `main': prog.cpp:(.text.startup+0x3): undefined reference to `i' collect2: error: ld returned 1 exit status
Standard output is empty