Skip to content

core: fix error: 'getenv' was not declared in this scope

Vadim Yanitskiy requested to merge vyanitskiy/titan.core:master into master

This patch fixes compilation errors with gcc v14.2.1:

g++ -c -DYY_NO_INPUT -DMEMORY_DEBUG -DFATAL_DEBUG -DYYDEBUG=1  -DLINUX -DUSE_EPOLL
    -I. -IRT1 -I/usr/include/libxml2 -I../common -Wno-error -Wno-changes-meaning
    -g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -fPIC
    XmlReader.cc -o XmlReader.o
XmlReader.cc: In member function ‘int XmlReaderWrap::ReadDbg(const char*)’:
XmlReader.cc:124:24: error: ‘getenv’ was not declared in this scope
  124 |   static boolean d = !!getenv("DEBUG_XMLREADER");
      |                        ^~~~~~
XmlReader.cc:25:1: note: ‘getenv’ is defined in header ‘<cstdlib>’;
                   this is probably fixable by adding ‘#include <cstdlib>’
   24 | #include "Encdec.hh"
  +++ |+#include <cstdlib>
   25 |
XmlReader.cc: In member function ‘int XmlReaderWrap::MoveToFirstAttributeDbg(const char*)’:
XmlReader.cc:294:24: error: ‘getenv’ was not declared in this scope
  294 |   static boolean d = !!getenv("DEBUG_XMLREADER");
      |                        ^~~~~~
XmlReader.cc:294:24: note: ‘getenv’ is defined in header ‘<cstdlib>’;
                     this is probably fixable by adding ‘#include <cstdlib>’
XmlReader.cc: In member function ‘int XmlReaderWrap::MoveToNextAttributeDbg(const char*)’:
XmlReader.cc:328:24: error: ‘getenv’ was not declared in this scope
  328 |   static boolean d = !!getenv("DEBUG_XMLREADER");
      |                        ^~~~~~
XmlReader.cc:328:24: note: ‘getenv’ is defined in header ‘<cstdlib>’;
                     this is probably fixable by adding ‘#include <cstdlib>’
XmlReader.cc: In member function ‘int XmlReaderWrap::MoveToElementDbg(const char*)’:
XmlReader.cc:362:24: error: ‘getenv’ was not declared in this scope
  362 |   static boolean d = !!getenv("DEBUG_XMLREADER");
      |                        ^~~~~~
XmlReader.cc:362:24: note: ‘getenv’ is defined in header ‘<cstdlib>’;
                     this is probably fixable by adding ‘#include <cstdlib>’

Merge request reports