Compile Error C1010

First off, I have already found a "work around", just I don't get why the "workaround" is working. To keep this simple, this is part of my file layout.

Project

--Folder 1

----A.cpp

----A.h

--stdafx.h

--stdafx.cpp

I listed only the relevent files. A.cpp contians...

#include "../stdafx.h" //Changing this to "stdafx.h" fixes the problem, but I don't know why, as the stdafx.h file is not in the same location as A.cpp .

#include "A.h"

Is there a reason that the compiler can't find the file when annotiated correctly, but putting "stdafx.h" fixes the problem. (also note, if you right-click "../stdafx.h" and select 'open document' VC opens the stdafx.h file, but right-clicking "stdafx.h" and selecting 'open document' brings up an error telling me it can't find the file in the directory or the build path. (which is correct)) But the latter is the correct version for the compiler... which does not make sense

My feeling is that I have a setting off, but all I will say is that my code compiles correctly in Dev-C++ (when I comment out the managed stuff of course). All I know is that this "fix" should not be working.

Thanks for any help you guys give me. If I forgot to post some infomation let me know.



Answer this question

Compile Error C1010

  • xxANTMANxx

    Yep, precompiling through stdafx.h is strange. Another doozy is putting an #include before stdafx.h, the compiler completely ignores it. If you think about it, it is really a rather nice feature. Imagine you have a folder with utility type source code that could be used by muliple projects. Such a source file would never be able to predict which stdafx.h it needs to include. Just by writing #include "stdafx.h", the compiler automagically includes the one the project uses...

    In other words: "it is a feature, not a bug!".



  • redcode

    Thanks, but it is odd, as it does not do as it is expected to do. I was more asking the reasoning behind this. This does not do what ISO C++ would do, so I was wondering other than the convience factor, is there any other uses for microsoft's changes.

    Agian, thanks for your reply, and to double check, for Microsoft's C++/CLI I need to put "stdafx.h" every time, no matter where the source is.


  • Compile Error C1010