Why is "stderr" not constant in the second scenario??

I'm new to Visual Studio 6.0 and am having difficulty understanding the differences between the standard Microsoft C Libraries used when compiling a simple console application. Here's my C code example:

#include <stdio.h>

static FILE *_logFile = stderr; /* Line with error */

int main(int argc, char **argv)
{
 fprintf(_logFile, "hello World");
}

There are two scenarios:
1. In the "Project Settings" Dialog under the "C/C++" Tab I set the "Category" to "Code Generation" and then the "Run-Time Library" to "Single Threaded *" or "Multithreaded". The Code compiles without warnings or errors. When I run the exe "Hello World" is printed (as expected) to the console.

2. I set the "Run-Time Library" to "Multitheaded dll". When Attempting to compile the code I get the following error:
error C2099: initializer is not a constant
It refers to the line I've marked.

So here's my question: Why is "stderr" not constant in the second scenario



Answer this question

Why is "stderr" not constant in the second scenario??

  • ManoranjanPatel

    I have also tried it with VC2005 and all seems to work as expected.

    Thanks,
      Ayman Shoukry
      VC++ Team

  • Daniel D.C.

    I've been trying your example with my copy of Visual C++ 6.0 and so far I have not been able to reproduce the problem.

    Could you run the compiler from the command-line with the /Bv option and let me know the output. This will let me know if you have all the Service-Packs installed.



  • Why is "stderr" not constant in the second scenario??