Hi everyone,
I have a strange problem with precompiled headers with VC8. I have the
problem while trying to use a precompiled header to build another
precompiled header. I tried the sample code provided on msdn for the
use of /Yu /Yc and while it works well with VC++ 7.0, it doesn't with
VC++ 8.0 (http://msdn2.microsoft.com/en-us/library/2yzw0wyd.aspx).
It gives me this error under VC 8:
level2.cpp(3) : fatal error C1083: Cannot open precompiled header file:
'level2.pch': The process cannot access the file because it is being
used by another process.
even when level2.pch doesn't exist and I try to change the names so it
would produce another .pch file. So nobody is trying to access
level2.pch.
Those are my sources (minimalist from
http://msdn2.microsoft.com/en-us/lib...yzw0wyd.aspx):
//File stuff.h
#pragma once
class SomeClass {};
//File level1.cpp
#include "stuff.h"
#pragma hdrstop("level1.pch")
//File morestuff.h
//empty
//File level2.cpp (as on msdn)
#include "stuff.h"
#include "morestuff.h"
#pragma hdrstop("level2.pch")
I used (as on msdn):
cl -c -Ycstuff.h -Fplevel1.pch level1.cpp
cl -c -Yustuff.h -Fplevel1.pch -Yc level2.cpp
both in the Visual Studio 2001 and Visual Studio 2005 command prompt
and it breaks with 2005 on the second command line. I also tried to
run it under 2001 after running the batch file that shows the Visual
Studio 2005 command prompt. It also breaks with the error given above.
Note that it's not an environment problem, since running the following
batch file reproduces the problem:
rem Works
call "C:\Program Files\Microsoft Visual Studio
..NET\Common7\Tools\vsvars32.bat"
cl -c -Ycstuff.h -Fplevel1.pch level1.cpp
cl -c -Yustuff.h -Fplevel1.pch -Yc level2.cpp
del level2.pch
rem Error saying that another process is accessing level2.pch.
call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"
cl -c -Ycstuff.h -Fplevel1.pch level1.cpp
cl -c -Yustuff.h -Fplevel1.pch -Yc level2.cpp
rem Works, so it's really VC8 locking the file...
call "C:\Program Files\Microsoft Visual Studio
..NET\Common7\Tools\vsvars32.bat"
cl -c -Ycstuff.h -Fplevel1.pch level1.cpp
cl -c -Yustuff.h -Fplevel1.pch -Yc level2.cpp
Thanks in advance
Regards,
Simon