title: Why such theoretically crossplatform code does not change Enviromental variable on Windows?
body: <p>So I try next code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;cstdlib&gt;
  #include &lt;sstream&gt;
  #include &lt;boost/filesystem/v3/path.hpp&gt;
  #include &lt;boost/filesystem/v3/operations.hpp&gt;
  #ifdef WIN
  #include &lt;Windows.h&gt;
  #endif
  
  void setEnviromentVariable(std::string name, boost::filesystem::path value)
  {
      if ( getenv (name.c_str())==NULL)
      {
          std::cout &lt;&lt; "Hit ENTER to restart application in order to agree with the next terms of use: do not eat my bytes!)" &lt;&lt; std::endl;
          std::stringstream VAR;
          VAR &lt;&lt; name&lt;&lt; "=" &lt;&lt; value.native().c_str();
             #ifdef WIN
          std::stringstream VAL;
          VAL &lt;&lt; value.native().c_str();
          if( !SetEnvironmentVariable(TEXT(name.c_str()), TEXT(VAL.str().c_str()))) 
          {
              printf("SetEnvironmentVariable failed (%d)\n", GetLastError()); 
          }
            #else
          setenv(VAR.str().c_str());
            #endif
          std::cin.get();
  
      }
  
  }
  int main(int argc, char *argv[])
  {
          boost::filesystem::path full_path( boost::filesystem::current_path() / "assets/" );
          setEnviromentVariable("TCL_LIBRARY", full_path);
  }
  </code></pre>
  
  <p>What is wrong with my code? Why it does not set up any enviroment variable, and why it does not show me any errors? (<a href="http://msdn.microsoft.com/en-us/library/ms682009%28VS.85%29.aspx" rel="nofollow">WIN code is based on this.</a>)</p>